Setting Event Handlers from within JavaScript : General Event : Event onMethod JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Event onMethod » General Event »

 

Setting Event Handlers from within JavaScript





<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>
           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Event onMethod
» General Event