J
Jeff Robichaud
Hi,
This seems like a classic one (but I'm pretty new to Javascript)...
I have a list of checkboxes for all the U.S. states and a checkbox "All" to
check them all at once. The following function performs this:
function CheckAll(masterCheckBox)
{
var arrayInput = document.getElementsByTagName("input");
for(i=0; i<arrayInput.length; i++)
{
if (arrayInput.type == "checkbox")
{
arrayInput.checked = masterCheckBox.checked;
}
}
}
Ok there's a little overhead because a form will contain a few input
elements that are not of checkbox type but it works (any better idea would
be appreciated).
Now if I want to include another set of checkboxes, say Canadian provinces,
that will also have their checkbox "All". How can I differentiate the two
checkbox sets ?
This seems like a classic one (but I'm pretty new to Javascript)...
I have a list of checkboxes for all the U.S. states and a checkbox "All" to
check them all at once. The following function performs this:
function CheckAll(masterCheckBox)
{
var arrayInput = document.getElementsByTagName("input");
for(i=0; i<arrayInput.length; i++)
{
if (arrayInput.type == "checkbox")
{
arrayInput.checked = masterCheckBox.checked;
}
}
}
Ok there's a little overhead because a form will contain a few input
elements that are not of checkbox type but it works (any better idea would
be appreciated).
Now if I want to include another set of checkboxes, say Canadian provinces,
that will also have their checkbox "All". How can I differentiate the two
checkbox sets ?