following javascript can control the selection of one check box at a time
function SelectOne(event, cname) {
if (!event)
event = window.event;
var listItem = event.target || event.srcElement;
var cbl = document.getElementById(cname);
var listItems = cbl.getElementsByTagName('input');
for (var i = 0; i < listItems.length; i++) {
if (listItems[i] != listItem) {
listItems[i].checked = false;
}
}
}
function SelectOne(event, cname) {
if (!event)
event = window.event;
var listItem = event.target || event.srcElement;
var cbl = document.getElementById(cname);
var listItems = cbl.getElementsByTagName('input');
for (var i = 0; i < listItems.length; i++) {
if (listItems[i] != listItem) {
listItems[i].checked = false;
}
}
}
Usage:
<asp:CheckBoxList ID="chkRegt" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow"
Onclick="SelectOne(event,'ctl00_MainContent_chkRegt');readCBLReg('ctl00_MainContent_chkRegt')">
<asp:ListItem Text="Yes">Yes</asp:ListItem>
<asp:ListItem Text="No">No</asp:ListItem>
</asp:CheckBoxList>
Onclick="SelectOne(event,'ctl00_MainContent_chkRegt');readCBLReg('ctl00_MainContent_chkRegt')">
<asp:ListItem Text="Yes">Yes</asp:ListItem>
<asp:ListItem Text="No">No</asp:ListItem>
</asp:CheckBoxList>
No comments:
Post a Comment