How we can
restrict checkboxlist to single selection
(Or)
How we can do
checkboxlist behaves like a radiobuttonlist
Javascript
Code:
<script type =
"text/javascript">
function
MutExChkList(chk)
{
var
chkList = chk.parentNode.parentNode.parentNode;
var
chks = chkList.getElementsByTagName("input");
for(var i=0;i<chks.length;i++)
{
if(chks[i]
!= chk && chk.checked)
{
chks[i].checked=false;
}
}
}
</script>
Design View of the
CheckBoxList:
<asp:CheckBoxList ID="cblSelect" runat="server" RepeatLayout="Flow" >
<asp:ListItem Text="Yes" Value="Y" onclick="MutExChkList(this);" ></asp:ListItem>
<asp:ListItem Text="No" Value="N" onclick="MutExChkList(this);"></asp:ListItem>
</asp:CheckBoxList>
No comments:
Post a Comment