There used to be a for each in in JS 1.6 and there is recently an array.foreach
But I suggest you use a for loop like this since you have a collection
function toggle(source) {
var checkboxes = document.getElementsByName('foo[]');
for (var i=0;i<checkboxes.length;i++) {
checkboxes[i].checked = source.checked;
}
}
3
solved Using for each to toggle checkboxes stopped working