Over a million developers have joined DZone.

Javascript Tp Check/uncheck The Header Check Box On Chile Check Boxes Check/uncheck

·
// Javascript tp check/uncheck the header check box on chile check boxes check/uncheck



function CheckChanged(headerCheckBox, childCheckBox) {
    var frm = document.forms[0];
    var allChildChecked;
    allChildChecked= true;
    for (i = 0; i < frm.length; i++) {
        e = frm.elements[i];
        if (e.type == 'checkbox' && e.name.indexOf(childCheckBox) != -1) {
 
            if (e.checked == false) {
                allChildChecked= false;
                break;
            }
        }
    }
    for (i = 0; i < frm.length; i++) {
        e = frm.elements[i];
        if (e.type == 'checkbox' && e.name.indexOf(headerCheckBox) != -1) {
            if (boolAllChecked == false)
                e.checked = false;
            else
                e.checked = true;
            break;
        }
    }
}

Topics:

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