How to pass tree object to function call?

If I have 2 dhtml Tree in a single page,how can I retrieve the tree object in javascript function call?

As I tried to get the treeObject with the following statements, the object return is not a tree object. All dhtmlTree’s function call are not valid.



function isValidMove(treeObj) {

treeX = document.getElementById(treeObj.id); // treeObj is the DIV id

alert(treeObj.id + “:” + treeX.getSelectedItemId()); // treeX is not an dhtmlTree object, is just a DIV

}



How can I pass/get the dhtmlTree object in a function? especially in the case that I have 2 trees in a single page?

I do not want to hardcode the tree object with tree1, tree2, tree3, … and so on …



Thanks in advance.

Inside any event handler you can use this as pointer to related object

mytree.attachEvent(“onClick”,function(id){
    alert(this.getSelectedItemId());
});

There is  no way to retrieve tree object from ID of tree container.