Example 6 - Referring to other form elements.

The first button reports its own value.

The second button tells the value of the first button.

Click the buttons.


The code for the form is:


    <form name="frmExample6" action="">
    
        <input type="button"
                  name="btnFoo"
                  value="See me"
                  onclick="alert('This button name: ' 
                                + this.name 
                                + '.  This button value: ' 
                                + this.value);" >

        <input type="button"
                  name="btnGoo"
                  value="See the other"
                  onclick="alert('Other button name: ' 
                                 + document.frmExample6.btnFoo.name 
                                 + '.  Other button value: ' 
                                 + document.frmExample6.btnFoo.value );" >
    </form>