dhtmlxMenu:set up onclick event dinamically throw href tag

Hi all,
I would apreciate any help. I am trying to generate the menu config xml, but I would like to set up the tag to launch a js function on click event, something like this:

<a href="javaScript:seleccionar('CircuitosAction.aao?opc=1');">link</a>

I have tried with the following code but it doesnt work:

<href>seleccionar('CircuitosAction.aao?opc=1');</href>

I have tried with the CDATA as well with the same result:

<href><![CDATA[seleccionar(CircuitosAction.aao?opc=1);]]></href> :smiley:

Any suggest??

Many thanks anyway

Hi,

try the following:

Hi Alexandra, thanks for the reply.
I Tryed your code but it isn´t succcess. The following is the generated xml:

[code]

javaScript:seleccionar(‘CircuitosAction.aao?opc=1’);

[/code]

but when I click in a button of the dhtmlxmenu I get this error in the firefox error console.

Error: unterminated string literal Source file: javascript:seleccionar('CircuitosAction.aao

The error seems to be something related with the chracter “?”, but I have no idea about what to do. :cry:

Thanks anyway

Hi again, I have tried diferent options, the following is the xml:

[code]













<item id='100' text='Administración'>
    <item id='01' text='test1'>
        <href>javaScript:seleccionar('CircuitosAction.aao?opc=1')</href>
    </item>        
    <item id='02' text='test2'>
        <href>javaScript:seleccionar(CircuitosAction.aao?opc=1)</href>
    </item>
    <item id='03' text='test3'>
        <href>javascript:seleccionar('CircuitosAction.aao?opc=1')</href>
    </item>
    <item id='04' text='test4'>
        <href>javascript:seleccionar(CircuitosAction.aao?opc=1)</href>
    </item>
    <item id='05' text='test5'>
        <href>CircuitosAction.aao?opc=1</href>
    </item>
    <item id='06' text='test6'>
        <href>seleccionar(CircuitosAction.aao?opc=1)</href>
    </item>
    <item id='07' text='test7'>
        <href>dhxLayout.cells("a").attachURL("CircuitosAction.aao?opc=1");</href>
    </item>
    <item id='08' text='test8'>
        <href>javascript:seleccionar("CircuitosAction.aao?opc=1")</href>
    </item>
</item>
[/code]

Hi,

there problem is caused by “?” in the parameter. You may use the following approach instead of hrefs:

<item id='21' text='Manual de usuario'> <userdata name="call">seleccionar</userdata> <userdata name="param">CircuitosAction.aao?opc=1</userdata> </item>

You need to define onClick event handler:

menu.attachEvent("onClick",function(id){ var call = this.getUserData(id,"call") if(call) window[call](this.getUserData(id,"param")) })