• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

Select/Deselect all checkboxes - how to ignore specific ones

Hello Experts,

Please see this example: Example

What I want to do is EXCLUDE the "other1" checkbox when doing a select/deselect all.
(Therefore, ticking all the checkboxes (regardless of whether this one is ticked) will tick the relevant select all checkbox(es)).

How can I modify the code to enable this?

Thanks!

0
jagku
Asked:
jagku
1 Solution
 
leakim971PluritechnicianCommented:
For example : http://jsfiddle.net/6pcE4/
$(function() {
    $('li.selectAll>input:checkbox').bind('click',function(){
        var root=$(this).closest('.mainNode');
        var ul=$(this).closest('ul');

        if('ALL'==this.value &&'LI'!=ul.parent().closest('ul').parent().get(0).nodeName.toUpperCase())
            $(':checkbox:not([value="other1"])',root).attr('checked',this.checked);
        else
            $('>li>input:checkbox:not([value="other1"])',$(this).closest('ul')).attr('checked',this.checked);
    });

    $('input[type=checkbox]').bind('click',function(){
        var root=$(this).closest('.mainNode');
        var ul=$(this).closest('ul');
        $('>li.selectAll>:checkbox:eq(0)',ul).attr('checked', $('>li>:checkbox:gt(0):checked',ul).size()==$('>li>:checkbox:gt(0):not([value="other1"])',ul).size() );
        $(':checkbox:eq(0)',ul).attr('checked', $(':checkbox:gt(0):checked',ul).size()==$(':checkbox:gt(0):not([value="other1"])',ul).size() );
        $(':checkbox:eq(0)',root).attr('checked', $(':checkbox:gt(0):checked',root).size()==$(':checkbox:gt(0):not([value="other1"])',root).size() );
    });

});

Open in new window

0
 
jagkuAuthor Commented:
Many thanks as usual!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now