Solved

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

Posted on 2011-09-09
2
340 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now