Check to Check All Checkboxes

[Total: 0    Average: 0/5]

Checkboxes can be all checked, and all unchecked based upon checking a box.

Body Code:

<form name=f1>
<input type="checkbox" name="c1" value="1">c1-1<BR>
<input type="checkbox" name="c1" value="2">c1-2<BR>
<input type="checkbox" name="c1" value="3">c1-3<BR>
<input type="checkbox" name="c1" value="4">c1-4<BR>
<input type="checkbox" name="c1" value="5">c1-5<BR>
<input type="checkbox" name="c2" value="1">c2-1<BR>
<input type="checkbox" name="c2" value="2">c2-2<BR>
<input type="checkbox" name="c2" value="3">c2-3<BR>
<input type="checkbox" name="c2" value="4">c2-4<BR>
<input type="checkbox" name="c2" value="5">c2-5<BR>
<HR>
<input type="checkbox" name="c3" value="false" onclick="doIt(this.value)">All Not Checked<BR>
<input type="checkbox" name="c4" value="true" onclick="doIt(this.value)">All Checked<BR>
</form>
<script>
function doIt(v)
{
 for(var i=0;i<document.f1.c1.length;i++)
   document.f1.c1[i].checked=eval(v);
 for(var i=0;i<document.f1.c2.length;i++)
   document.f1.c2[i].checked=eval(v);
 document.f1.c3.checked=false;
 document.f1.c4.checked=false;
}
</script>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *