A link for each option

Hi all!

I have a tree with some nodes created dynamically, and i need to link every option to a diferent screen using id parameter.

As you can see, different children are created using the cursor and the loop inside. It works, the tree is ok, but the function ‘tonclick’ doesn´t work correctly.

Thanks a lot for your time!

Hi
Recommend you using one global event handler “onClick” with different requirements in it:
docs.dhtmlx.com/doku.php?id=dhtm … nt_onclick
Or you can apply event handler directly to each item when you add it:
docs.dhtmlx.com/doku.php?id=dhtm … newchild&s[]=insertnewchild
There is an “itemActionHandler” parameter, there you can put any function.

First of all, thanks for the reply.

I have this:

The problem now is that the pages open automatically every time that the web is load, all of them, instead of when i choose the option. In fact, the links doesn´t work when i click on it.

Ok, i use this and it works perfect…

tree.attachEvent(“onClick”,function(id){
if (id == 10)
{
var site = “bda_inicio_ayudas.ejecuta_opcion_menu?p_k=’||k||’&p_menu=GSOLICITUDUNICA&p_submenu=ENVIOSOLUN”
window.location.href(site)
}
else if (id == 20)
{
var site = “bda_inicio_ayudas.ejecuta_opcion_menu?p_k=’||k||’&p_menu=GSOLICITUDUNICA&p_submenu=CRUCESSOLU”
window.location.href(site)
}
})

Thanks again! :wink: