Over a million developers have joined DZone.

Javascript For Verifying That Atmost Single Record Is Selected In The Grid

·
// Javascript for verifying that atmost single record is selected in the grid



function ChecksingleSelected(checkBox) {
 
    var frm = document.forms[0];
    var flag = false;
    var cnt = 0;
 
    for (var i = 0; i < document.forms[0].length; i++) {
        if (document.forms[0].elements[i].id.indexOf(checkBox) != -1) {
            if (document.forms[0].elements[i].checked) {
                flag = true
                cnt = cnt + 1;
            }
        }
    }
    if (cnt > 1) {
       
        alert('Only record can be seleccte/checked.');
        return false;
    }

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}