Creating an array of children

Posted on 2011-10-14
Last Modified: 2012-05-12
Hello Experts,

Please see this example:

What I would like to do is when the user clicks a 'Select All' node, an array is populated
containing all its siblings and any of the siblings' children.

For example, if the user clicks on the top 'Select all', I want the array to contain:

If they click on the Select All under Sub 1 then the array should contain:

What do I need to do to achieve this?

Question by:jagku
    LVL 3

    Assisted Solution

    by:Piotr D
    What do you need to do to achieve this? First of all, you should not re-invent the wheel ;)

    It would be faster/safer/better to use an already created jQuery plugins fot a checkbox tree, like either of those:


    The latter is probably the best free plugin you can find out there (at least I did not find anything better). It appears to have already the functionality you need. Take a look at the Example browser, select "Checkbox & select", example no. 3. The plugin supports proper hierarchical selecting/deselecting and gives you methods to get selected keys/nodes. Cool, isn't it? ;)

    If you need further assistance, let me know.
    LVL 81

    Accepted Solution

    Test page :

    $(function() {
        $(':checkbox[value="ALL"]').bind("click",function() {
            var arr = [];
            $(this).closest("ul").find(":checkbox").not(this).each(function() { arr.push($(this).val()); });

    Open in new window


    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Hello World !, Thanks : My Sincere thanks to @Michael Male who encouraged me to write an article on this in my  blog ( Introduction:       There are several technical issues a developer may face in his…
    Introduction HyperText Transfer Protocol ( 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…
    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.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    729 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

    19 Experts available now in Live!

    Get 1:1 Help Now