Snookerman
05-05-2010, 10:21 AM
I want to go through all checkboxes (all inputs are checkboxes) on a page and uncheck them if they are checked. This is what I came up with:
checkboxes = document.getElementsByTagName('input');
for (var index = 0; index < checkboxes.length; index++){
checkboxes[index].checked = false;
}
My first instinct was to just do one of these:
checkboxes = document.getElementsByTagName('input');
checkboxes.checked = false;
//or
checkboxes[all].checked = false;
That of course doesn't work, but is there any other way to do something to all items in an array without using loops? Thanks!
checkboxes = document.getElementsByTagName('input');
for (var index = 0; index < checkboxes.length; index++){
checkboxes[index].checked = false;
}
My first instinct was to just do one of these:
checkboxes = document.getElementsByTagName('input');
checkboxes.checked = false;
//or
checkboxes[all].checked = false;
That of course doesn't work, but is there any other way to do something to all items in an array without using loops? Thanks!