Solved

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

Posted on 2011-09-09
2
347 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
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 …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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