I have a CheckBoxList id="cblFiles" and a CheckBox id="Checkbox1".
I have added checkAll functionality to the CheckBoxList. And now what I need to check is if any CheckBox in the CheckBoxList is unchecked “Checkbox1” should be unchecked.
Following code doesn’t work for me
function SelectNoneCheckboxes() {
var elm = document.getElementById("<%=cblFiles.ClientID %>");
for (i = 0; i < elm.childNodes.length; i++) {
if (elm.childNodes[i].checked == false) {
document.getElementById("<%=Checkbox1.ClientID %>").checked = false;
}
}
}
code for the checkAll Functionality
function SelectAllCheckboxes(spanChk) {
var oItem = spanChk.children;
var theBox = (spanChk.type == "checkbox") ?
spanChk : spanChk.children.item[0];
xState = theBox.checked;
elm = theBox.form.elements;
for (i = 0; i < elm.length; i++)
if (elm[i].type == "checkbox" &&
elm[i].id != theBox.id) {
if (elm[i].checked != xState)
elm[i].click();
}
}
1 Answer