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

Select/unselect All Checkboxes In Grid

01.30.2012
| 2793 views |
  • submit to reddit
        // Select/unselect all checkboxes in grid


function SelectAllCheckBoxesInGrid(gridHeaderCheckBoxId, gridChildCheckBoxId) {
    var frmElements = document.forms[0].getElementsByTagName('input');
    for (i = 0; i < frmElements.length; i++) {
        if (frmElements[i].type == "checkbox" && frmElements[i].id.indexOf(gridChildCheckBoxId, 0) >= 0) {
            if (frmElements[i].disabled == false) {
                frmElements[i].checked = gridHeaderCheckBoxId.checked;
            }
        }
    }
    return false;
}