Using the HTML Form Elements Array : CheckBox : Form Control : JavaScript DHTML examples (example source code) Organized by topic

JavaScript DHTML
C++
PHP
JavaScript DHTML Home »  Form Control   » [  CheckBox  ]   
 



Using the HTML Form Elements Array

Please note that some example is only working under IE or Firefox.

/*

Learn How to Program Using Any Web Browser
by Harold Davis 

Apress CopyRight 2004

ISBN: 1590591135
*/
<HTML>
<HEAD>
<TITLE>    Elements Array    </TITLE>
</HEAD>
<BODY>
<SCRIPT
   function uClicked (theBox){ 
      if (!theBox.checked
         alert ("You unchecked the box.")
      else 
         alert ("You checked the box.")
   
   function clearChecks(form){ 
      for (var i = 0; i < 100; ++i) { 
         form.elements[i].checked = false
      
   
   function checkAll(form){ 
      for (var i = 0; i < 100; ++i) { 
         form.elements[i].checked = true
      
   
   document.write("<form><CENTER>"
      document.write("<font size=6 face='Courier'>")
      for (var i = 0; i < 10; ++i) { 
         document.write(i)
      
      document.write("</font><br>")
   for (var i = 0; i < 10; ++i) { 
      document.write("<font size=6 face='Courier'>")
      document.write(i)
      document.write("</font>")
      for (var j = 0; j < 10; ++j) { 
         document.write('<INPUT TYPE="checkbox" '); 
         document.write('onClick="uClicked(this)">'); 
      
      document.write("<BR>")
   
   document.write("<BR>")
   document.write("<HR SIZE=1 WIDTH=40%>")
   document.write('<INPUT TYPE="button" VALUE="Check All" '); 
   document.write('onClick="checkAll(this.form)">') 
   document.write('<INPUT TYPE="button" VALUE="Clear Checks" '); 
   document.write('onClick="clearChecks(this.form)">') 
   document.write("</center></FORM>"
   </SCRIPT>
</BODY>
</HTML>
           
       
Related examples in the same category
1.  Call 'click()' to triger event
2.  'defaultChecked' Example
3.  Check status Example
4.  'indeterminate' Example
5.  CheckBox check action
6.  Checkbox in a form
7.  Check and uncheck a checkbox
8.  Checkboxes in a form
9.  Checkbox Action
10.  Determining Whether a Checkbox Object Is Checked
11.  The Checkbox Object's checked Property
12.  The checked Property as a Conditional
13.   A Checkbox and an onClick event Handler
14.  Check a CheckBox
15.  Is checked
16.   Methods and Properties of the Checkbox Object
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.