I have the following function to toggle check boxes to checked and unchecked. I have two sets of discrete check boxes on the page
The problem is I would like to only check 1 set and not the
other. As the amount of checkboxes and other inputs vary (dynamic search) I cannot use
(vari=6;i<document.frmSearch.elements.length;i++)
to start at the 6th element of the form (the first checkbox on the page)
Here is the code so far:
The problem is I would like to only check 1 set and not the
other. As the amount of checkboxes and other inputs vary (dynamic search) I cannot use
(vari=6;i<document.frmSearch.elements.length;i++)
to start at the 6th element of the form (the first checkbox on the page)
Here is the code so far:
Code:
//toggle the first set of chechboxes
function WLToggle() {
if (document.frmSearch.elements'chkWLToggle'].checked==false) {
for(var i=6;i<10;i++)
document.frmSearch.elements[i].checked=false;
}
else {
for(var i=6;i<10;i++)
document.frmSearch.elements[i].checked=true;
}
}
//toggle the second set of chechboxes
function SLToggle() {
if(document.frmSearch.elements'chkSLToggle'].checked==false) {
for(var i=12;i<document.frmSearch.elements.length;i++)
document.frmSearch.elements[i].checked=false;
}
else {for(var i=12;i<document.frmSearch.elements.length;i++)
document.frmSearch.elements[i].checked=true;
}
}
<body>
<td><input type=checkbox name='chkWLToggle' id='chkWLToggle' onclick='WLToggle()' checked></td>
<td><INPUT id=cbo3701 name=cbo3701 type=checkbox Checked style="VISIBILITY: visible"></td>
<td><INPUT id=cbo3702 name=cbo3702 type=checkbox Checked style="VISIBILITY: visible"></td>
<td><INPUT id=cbo3703 name=cbo3703 type=checkbox Checked style="VISIBILITY: visible"></td>
etc..
<td>
<input type=checkbox name='chkSLToggle' id='chkSLToggle' onclick='SLToggle()' checked></td>
<td><INPUT id=cbo3707 name=cbo3707 type=checkbox Checked style="VISIBILITY: visible"></td>
<td><INPUT id=cbo3708 name=cbo3708 type=checkbox Checked style="VISIBILITY: visible"></td>
<td><INPUT id=cbo3709 name=cbo3709 type=checkbox Checked style="VISIBILITY: visible"></td>
etc..