Monday, November 28, 2011

uncheck the check box if another check box checked in check box list or radio button list

Here i will unchecked  items  in radio button list server control or check box list server control when we select on any item in this  .For this i have used a  singleitemcheck() function for each item in list control .This function makes functionality is very quick in your application

Aspx Page:
<asp:radiobuttonlist id="contentcheck" repeatdirection="Horizontal" runat="server">
<asp:listitem onclick="singleitemcheck(this);">Home</asp:listitem>
<asp:listitem onclick="singleitemcheck(this);">Pages</asp:listitem>

Java Script:
function singleitemcheck(ch) {
            var chkList = ch.parentNode.parentNode.parentNode;
            var chks = chkList.getElementsByTagName("input");
            for (var i = 0; i < chks.length; i++) {
            if (chks[i] != ch&& ch.checked) {
                chks[i].checked = false;

No comments: