<HTML>
<HEAD>
<TITLE>Setting event handlers from within JavaScript</TITLE>
<SCRIPT LANGUAGE="JavaScript"><!--
function handler1() {
document.test.result.value="Set by handler1"
document.test.clickMe.onclick=handler2
}
function handler2() {
document.test.result.value="Set by handler2"
document.test.clickMe.onclick=handler1
}
//--></SCRIPT>
</HEAD>
<BODY>
<FORM NAME="test">
<INPUT TYPE="BUTTON" NAME="clickMe" VALUE="Click Me!">
<P><INPUT TYPE="TEXT" NAME="result" SIZE="20"></P>
</FORM>
<SCRIPT LANGUAGE="JavaScript"><!--
document.test.clickMe.onclick=handler1
//--></SCRIPT>
</BODY>
</HTML>
|