Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
my script does not work

i have added my sourcode below

        <script>
            $(function(){
                $('selectall-form').click(function(event) {
                    if(this.checked) {
                        $('.bluebutton3').each(function() {
                            this.checked = true;
                        });
                    }
                    if(!this.checked) {
                        $(':checkbox').each(function() {this.checked = false;});
                    }
                });
            });
        </script>
input
    <input type="checkbox" name="t1" class="checkbox">

    <input type="checkbox" name="t2" class="checkbox">

button
<input type="button" name="selectall-form" class="bluebutton3" value="Select All">
Posted
Updated 15-Oct-13 21:15pm
v5

1 solution

Try this Code

C#
$(function(){
    $('.bluebutton3').click(function(){
        var select_all = (this.value === 'Select All');
        $('input:checkbox').attr('checked', select_all);
        this.value = (select_all) ? 'Deselect All' : 'Select All';
    });
});
 
Share this answer
 
Comments
Nico_Travassos 16-Oct-13 4:02am    
Thank you it works

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900