JQuery Check/Uncheck a checkbox group

Check/Uncheck a checkbox group using JQuery

When you have a checkbox group where the name is an array you can use this script to check/uncheck all the entire group

 

Header, remember to include the JQuery library:

<script type="text/javascript" src="jquery-1.4.4.min.js">
<script type="text/javascript">
        $(document).ready(function() {
           $("#chkAll").toggle(
            function() {
            $('input[type=checkbox]').attr('checked', 'true');
            },
            function() {
            $('input[type=checkbox]').removeAttr('checked');           
            });         
        });
        
</script>

        

Body:

       
Javascript supports the following programming paradigms:<br>
<input type="checkbox" name="paradigm[]" value="Imperative">Imperative<br>
<input type="checkbox" name="paradigm[]" value="Object-Oriented">Object-Oriented<br>
<input type="checkbox" name="paradigm[]" value="Functional">Functional<br><br>        
<input type="checkbox" id="chkAll">Select All<br>

That simple!