Mega Code Archive

 
Categories / JavaScript DHTML / Form Control
 

Using the document forms Property

<HTML> <HEAD> <TITLE>document.forms example</TITLE> <SCRIPT LANGUAGE="JavaScript"> function myFunction() {     if (document.forms[0].bluish.checked) {         alert("Now going to the Blues music area...")     } else {         alert("Now going to Rock music area...")     } } </SCRIPT> </HEAD> <BODY> <FORM NAME="theBlues"> <INPUT TYPE="checkbox" NAME="bluish">Check here if you've got the blues. </FORM> Text<HR>Text<HR>Text<HR>Text<HR>Text<HR>Text<HR>Text<HR>Text<HR> <FORM NAME="visit"> <INPUT TYPE="button" VALUE="Visit music site" onClick="myFunction()"> </FORM> </BODY> </HTML>