JavaScript function to check/unckeck TreeView

Hi Experts,

How can I use javascript to check/uncheck all child nodes (one level down) then the checkBox of a treeView node is changed?

Also when a checkBox is UnCkecked how can I make sure its parent is also unchecked?

thanks a lot
Who is Participating?
function UncheckAllNode(check)
        var src=null;
        var treeview = document.getElementById("_treeGroup"); //use your treeview id instead of Tree1
        var treeLinks = treeview.getElementsByTagName("a");      
           var parentTable = GetParentByTagName("table", src);
           var nxtSibling = parentTable.nextSibling;
            if(nxtSibling && nxtSibling.nodeType == 1)//check if nxt sibling is not null & is an element node
                if(nxtSibling.tagName.toLowerCase() == "div") //if node has children
                    //check or uncheck children at all levels
            var childChkBoxes = parentTable.getElementsByTagName("input");  //check or uncheck the all main node

kateLAuthor Commented:
Hi sabeesh, that function is supposed to check all nodes in the treeView. Not check the child nodes of a particular node which is what I want.

And it crashes

It has things like getElementsByTagName("a"), GetParentByTagName("table", src), getElementsByTagName("input") ... which are not applicable. I don't have "a", "table" or "input" defined anywhere.

Can you please explain the code and how I can tweak it to do what I want?

Thanks sabeesh
kateLAuthor Commented:
Thank a lot kvimal
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.