[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • 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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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