onClick Master Checkbox to Check all checkbox Using Javascript use the following code will help you to check and uncheck all checkbox by master checkbox. 


<!DOCTYPE html>
        <title>Master Checkbox</title>
    <input type="checkbox" onClick="toggle(this)" /> Master checkbox<br/>
    <input type="checkbox" name="check" value="check1"> check 1<br/>
    <input type="checkbox" name="check" value="check2"> check 2<br/>
    <input type="checkbox" name="check" value="check3"> check 3<br/>
    <input type="checkbox" name="check" value="check4"> check 4<br/>
        function toggle(source) {
            checkboxes = document.getElementsByName('check');
            for (var i = 0, n = checkboxes.length; i < n; i++) {
                checkboxes[i].checked = source.checked;

Run the following code and see the results


Master checkbox

check 1

check 2

check 3

check 4