• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Using Check Boxes

It’s fairly easy to handle check boxes in your code. Here’s an example that displays a number of check boxes and uses the ONCLICK attribute to display a message when you click a check box, indicating which check box you clicked:

(Listing 12-12.html on the web site)

<HTML> 
    <HEAD> 
        <TITLE>Using Check Boxes</TITLE> 
        <SCRIPT LANGUAGE="JavaScript"> 
            <!--
            function check1Clicked()
					{
					document.form1.text1.value = "You clicked check box 1."
					}
					function check2Clicked()
					{
					document.form1.text1.value = "You clicked check box 2."
					}
					function check3Clicked()
					{
					document.form1.text1.value = "You clicked check box 3."
					}
					function check4Clicked()
					{
					document.form1.text1.value = "You clicked check box 4."
					}
					function check5Clicked() {
					document.form1.text1.value = "You clicked check box 5."
					} 
               // --> 
        </SCRIPT> 
    </HEAD> 

    <BODY> 
        <H1>Using Check Boxes</H1> 

        <FORM NAME="form1"> 
            <TABLE BORDER BGCOLOR = CYAN WIDTH = 200>
				<TR><TD><INPUT TYPE = "CHECKBOX" NAME = "check1" ONCLICK = "check1Clicked()">Check 1</TD></TR>
				<TR><TD><INPUT TYPE = "CHECKBOX" NAME = "check2" ONCLICK = "check2Clicked()">Check 2</TD></TR>
				<TR><TD><INPUT TYPE = "CHECKBOX" NAME = "check3" ONCLICK = "check3Clicked()">Check 3</TD></TR>
				<TR><TD><INPUT TYPE = "CHECKBOX" NAME = "check4" ONCLICK = "check4Clicked()">Check 4</TD></TR>
				<TR><TD><INPUT TYPE = "CHECKBOX" NAME = "check5" ONCLICK = "check5Clicked()">Check 5</TD></TR>
					</TABLE> 
            <BR> 
            <BR> 
            <INPUT TYPE="TEXT" NAME="text1" SIZE="30"> 
         </FORM> 
    </BODY> 
</HTML> 

					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint