View Full Version : select parentnode from childnode checkbox

08-24-2007, 08:26 AM
Hi all,
I'm having a problem. with a treeview, I am able to check all the checkboxes of the childitems in the treeview when a parent is checked. but now I am unsure of how, if I check a childnode, would I then check the parentnode?

thanks in advance.

08-24-2007, 08:44 AM
Much would depend upon your markup. A check box cannot be a parentNode of anything. A different way of looking at your markup, or a different markup may be required.

It would be much easier to reference the 'parent' check box by its name or id.

08-24-2007, 09:01 AM
ah, I see what you mean. the problem is that I'm getting the data from a database and adding it by looping through two datasets (one with parentnodes, the other with child nodes of the particular parent node) in asp.net. my javascript skills are very limited, so I am unsure whether I could somehhow use those datasets (or an equivalent) to get the name of the "child" and then register that it has that particular "parent". The main reason why I want to use javascript to try achieve this is so I don't cause a postback.

08-24-2007, 03:37 PM
Generally, for a check box to have much use in asp and other server side code, it has a name that holds its value when the form that contains it is submitted.

If the 'parent' check box in question is truly in a unique parentNode of these 'child' check boxes (and depending upon the organization of things, the parentNode could be the parentNode of other sets of children) , you could try:


For example, let's say your child check box is represented by the variable ch, and you wanted to check the 'parent' check box with a name of master1:


If there isn't already a name for this check box, it would be better to give it a unique (id's must be unique on a given page) id, or use the one it has if it has one. Then the code gets much simpler, as no reference to the child or any aspects of the document's structure are needed:


There are also ways to 'walk' the structure of a form (as opposed to the actual document tree) in javascript. This might be more useful in your case, it all depends on the markup you are dealing with.