0
我有一个CheckBoxList id="cblFiles"
和CheckBox id="Checkbox1"
。复选框列表检查功能
我已将checkAll功能添加到CheckBoxList。现在我需要检查的是,CheckBoxList中的任何CheckBox是否未选中“Checkbox1”应该是未选中的。
下面的代码不会对我
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;
}
}
}
的checkAll功能的代码工作
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();
}
}
现在,它给我的问题与checkAllfunctionality.I有,我已经添加checkAll功能检查中的CheckBoxList所有的复选框被选中的checkboxlist.actually当“Checkbox1”挂在嘴边。未选中时,checkboxlist未被选中。 – chamara 2011-06-09 19:17:07
@chamara,你的checkAll功能绑定到'Checkbox1'的'onchange'事件或其onclick事件吗?看起来好像它被绑定到'onchange',并且可能应该被移到'onclick'上。 – 2011-06-09 19:19:31
它绑定到onclick事件 – chamara 2011-06-09 19:21:39