DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

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

01.27.2012
| 4210 views |
  • submit to reddit
        // 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;
    }