PDA

View Full Version : passing a function within an anchor tag


jinx1981
01-12-2007, 12:49 AM
Hello,

I have a questionregarding passing a function within an anchor element href
during dom scripting using javascript.
for eg
the xslt file contains
<a href="javascript:{@test}('{@value}')">
how will i write this in javascript.

Basically the xml file has

test = "help" and no value parameter in this particular xml file currently

the basic idea is to pass help('') in href of anchor tag
the help function is already defined.

i have currently written as:
var help = element.getAttribute('test');
var value = element.getAttribute('value');
elementA.href = 'javascript:help + '(' + value + ')';

value should be equal to ' ' where as in my case it is returning null and not sure on the syntax that i am using for href
Please help me

david_kw
01-12-2007, 01:12 AM
var help = element.getAttribute('test');
var value = element.getAttribute('value');
elementA.href = 'javascript:help + '(' + value + ')';


Try

elementA.href = "javascript:" + help + "(" + value + ");";

And see if that works any better.

david_kw