Home > DeveloperSection > Interviews > How to set all checkboxes to true using JavaScript?

Posted on    October-17-2011 12:16 AM

 JavaScript JavaScript 
Ratings:
 1 Answer(s)
  2035  View(s)
Rate this:

Chris Anderson
Chris Anderson

Total Post:197

Points:985
Posted on    October-17-2011 12:00 AM

//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;
}
}
}


Don't want to miss updates? Please click the below button!

Follow MindStick