Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toggle multiple checkboxes on single page

Status
Not open for further replies.

MikeyK

Programmer
Jul 29, 2001
7
AU
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:

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=&quot;VISIBILITY: visible&quot;></td>
<td><INPUT id=cbo3702 name=cbo3702  type=checkbox Checked  style=&quot;VISIBILITY: visible&quot;></td>
<td><INPUT id=cbo3703 name=cbo3703  type=checkbox Checked  style=&quot;VISIBILITY: visible&quot;></td>
etc..


<td>
<input type=checkbox name='chkSLToggle' id='chkSLToggle' onclick='SLToggle()' checked></td>

<td><INPUT id=cbo3707 name=cbo3707  type=checkbox Checked  style=&quot;VISIBILITY: visible&quot;></td>
<td><INPUT id=cbo3708 name=cbo3708  type=checkbox Checked  style=&quot;VISIBILITY: visible&quot;></td>
<td><INPUT id=cbo3709 name=cbo3709  type=checkbox Checked  style=&quot;VISIBILITY: visible&quot;></td>
etc..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top