Solved

Select/Deselect all in a <ul> 'tree' structure

Posted on 2011-09-09
2
342 Views
Last Modified: 2012-05-12
Hello Experts,

Please see the following link for my progress so far:

Example

(To be honest, I have had to delete the jquery as I simply can't get it to work!)

I am trying to achieve the following:

When a user clicks on the Select all box, I want ALL the children (including any grandchildren etc) to be ticked. Likewise, if the user then untick the box, it should do the opposite.

Many thanks for any help!
0
Comment
Question by:jagku
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36510225
try : http://jsfiddle.net/ZzTZP/

$(":checkbox", "li:contains('Select All')").click(function() {
    $(this).closest("ul").find(":checkbox").attr("checked", $(this).is(":checked") );
})

Open in new window


you may create/set a class for each checkbox "Select All" and use :

"li.selectAllClass" instead  "li:contains('Select All')"
0
 

Author Closing Comment

by:jagku
ID: 36510306
Many Thanks.
As suggested, I added <li class="selectAll">
and changed the

$(":checkbox", "li:contains('Select All')").click(function() {

to

$(":checkbox", "li.selectAll").click(function() {
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is basically two types of AJAX request in mootools. Request  and Request.HTML Request: Request is the basic XHR request class in MooTools. While not extremely useful on its own, it provides the basic functionality for both Request.HTM…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question