JavaScript in the Browser

Event Handler Scope

<form>
<input id="b1" type="button" value="Click Me 1"
   onclick="alert(this.form.b2.value)"/>

<input id="b2" type="button" value="Click Me 2"
   onclick="alert(form.b1.value)"/>

<input id="b3" type="button" value="Click Me 3"
   onclick="alert(b4.value)"/>

<input id="b4" type="button" value="Click Me 4"
   onclick="alert(getElementById('b3').value)"/>
</form>

José M. Vidal .

45 of 66