Tuesday, July 2, 2013

Javascript - how to select one checkbox from a checkbox list in asp.net using javascript

To select one checkbox from a checkbox list

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;
                }
            }
        }


No comments:

Post a Comment