Using the HTML Form Elements Array
<HTML> <HEAD> <TITLE>Elements </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; } } </SCRIPT> <form><CENTER> <INPUT TYPE="checkbox" onClick="uClicked(this)"> <INPUT TYPE="checkbox" onClick="uClicked(this)"> <INPUT TYPE="checkbox" onClick="uClicked(this)"> <INPUT TYPE="checkbox" onClick="uClicked(this)"> <INPUT TYPE="checkbox" onClick="uClicked(this)"> <INPUT TYPE="checkbox" onClick="uClicked(this)"> <INPUT TYPE="button" VALUE="Check All" onClick="checkAll(this.form)"> <INPUT TYPE="button" VALUE="Clear Checks" onClick="clearChecks(this.form)"> </FORM> </BODY> </HTML>