Basic JavaScript Question:
Download Questions PDF

To set all checkboxes to true using JavaScript?

Answer:

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

Download JavaScript Interview Questions And Answers PDF

Previous QuestionNext Question
You have an ASP. NET web application running on a web-farm that does not use sticky sessions - so the requests for a session are not guaranteed to be served the same machine. Occasionally, the users get error message Validation of view state MAC failed. What could be one reason that is causing this error? How to select an element by id and swapping an image?