Re: Keep track of parent node
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Keep track of parent node

From: impaler <TamasJano@gmail.com>
Date: Tue Jan 31 2006 - 12:18:47 CET

rmlakshmanan@gmail.com wrote:
> In javascript a tree structure node i have a subnode and it has
> parentnode and that parentnode has one parent how do i get all parent
> node when i click the subnode

var arrayParents = new Array;
if (child.parent) {
  var currentParent = child.parent;
  arrayParents.push(currentParent);
  while(currentParent.parent) {
     currentParent = currentParent.parent;
     arrayParents.push(currentParent);
  }
}

and there you have the array of parents. Adapt this algorithm to your
tree and code
Received on Tue Feb 7 21:28:33 2006