I have a datagrid with 2 columns of checkboxes. The one column has a header checkbox with the following "check all" code.
The problem is, is that this code is checking all checkboxes on the page. However, I only want the one column of checkboxes to get affected. Is there an attribute that I can check to do this? I was thinking I could check against the name of the checkbox with something like this...however, I wasn't sure if there is a like type statement in JS
"...your mom goes to college..."
Code:
function checkall(chk){
//check all checkboxes
var checkValue = chk.checked;
if ( chk.checked ){
chk.checked = false;
} else {
chk.checked = true;
}
count = document.forms[0].elements.length;
for (i=0; i < count; i++) {
if ( document.forms[0].elements[i].type.toLowerCase() == "checkbox") {
document.forms[0].elements[i].checked = checkValue;
}
}
}
The problem is, is that this code is checking all checkboxes on the page. However, I only want the one column of checkboxes to get affected. Is there an attribute that I can check to do this? I was thinking I could check against the name of the checkbox with something like this...however, I wasn't sure if there is a like type statement in JS
Code:
document.forms[0].elements[i].ID.toLowerCase().contains("chx")
"...your mom goes to college..."