To set all checkboxes to true using JavaScript?

Q

To set all checkboxes to true using JavaScript?

✍: Guest

A

//select all input tags
function SelectAll() {
var checkboxes = document.getElementsByTagName("input");
for(i=0;i<checkboxes.length;i++) {
if(checkboxes.item(i).attributes["type"].value == "checkbox") {
checkboxes.item(i).checked = true;
}
}
}

2011-01-11, 3048👍, 0💬