///HTML
<asp:CheckBoxList ID="CheckBoxList1" RepeatDirection="Vertical" runat="server" onclick="javascript: changeSelectAll ()">
</asp:CheckBoxList>
<asp:CheckBox ID="CheckBox1" runat="server" onclick="javascript: CheckBoxListSelect (this.id)" />
//CheckBoxList function
function CheckBoxListSelect(chkid, chblid) {
var chkBoxList = document.getElementById('<%= CheckBoxList1.ClientID %>');
var chkB = document.getElementById(chkid);
if (chkB.checked) {
var chkBoxCount = chkBoxList.getElementsByTagName("input");
for (var i = 0; i < chkBoxCount.length; i++) {
chkBoxCount[i].checked = true;
}
}
if (!chkB.checked) {
var chkBoxCount = chkBoxList.getElementsByTagName("input");
for (var i = 0; i < chkBoxCount.length; i++) {
chkBoxCount[i].checked = false;
}
}
return false;
}
//CheckBoxList function
function changeSelectAll() {
var chkBoxList = document.getElementById('<%= CheckBoxList1.ClientID %>');
var chkb = document.getElementById('<%= CheckBox1.ClientID %>')
var chekb = true;
var chkBoxCount = chkBoxList.getElementsByTagName("input");
for (var i = 0; i < chkBoxCount.length; i++) {
if (!chkBoxCount[i].checked) {
chekb = false;
break;
}
}
if (chekb) { chkb.checked = true; } else { chkb.checked = false; }
return false;
}
<asp:CheckBoxList ID="CheckBoxList1" RepeatDirection="Vertical" runat="server" onclick="javascript: changeSelectAll ()">
</asp:CheckBoxList>
<asp:CheckBox ID="CheckBox1" runat="server" onclick="javascript: CheckBoxListSelect (this.id)" />
//CheckBoxList function
function CheckBoxListSelect(chkid, chblid) {
var chkBoxList = document.getElementById('<%= CheckBoxList1.ClientID %>');
var chkB = document.getElementById(chkid);
if (chkB.checked) {
var chkBoxCount = chkBoxList.getElementsByTagName("input");
for (var i = 0; i < chkBoxCount.length; i++) {
chkBoxCount[i].checked = true;
}
}
if (!chkB.checked) {
var chkBoxCount = chkBoxList.getElementsByTagName("input");
for (var i = 0; i < chkBoxCount.length; i++) {
chkBoxCount[i].checked = false;
}
}
return false;
}
//CheckBoxList function
function changeSelectAll() {
var chkBoxList = document.getElementById('<%= CheckBoxList1.ClientID %>');
var chkb = document.getElementById('<%= CheckBox1.ClientID %>')
var chekb = true;
var chkBoxCount = chkBoxList.getElementsByTagName("input");
for (var i = 0; i < chkBoxCount.length; i++) {
if (!chkBoxCount[i].checked) {
chekb = false;
break;
}
}
if (chekb) { chkb.checked = true; } else { chkb.checked = false; }
return false;
}
No comments:
Post a Comment