calling javascript function in xsl

M

moralbarometer

Hallo,
I intend to have an html file generated with xsl. i want to have this
line below in the html file.

<a id="1" href="#" onclick="makeRequest('VALUE INSERTED USING XSL FROM
XML')" > test</a>

i have tried to produce this line but it was difficult working with
the ' ' in the javascript function which i really need in the function.
this is what i did. i created an xsl variable to hold hold the input
parameter of the javascript function--makeRequest. i make onclick as
an attribute created by xsl.
in the xsl atribute onclick i used xsl-vaue-of to create
makeRequest('VALUE INSERTED USING XSL FROM XML'). but '' was difficult
inserting. Please kindly help
 
P

p.lepin

moralbarometer said:
<a id="1" href="#" onclick="makeRequest('VALUE INSERTED
USING XSL FROM XML')"> test</a>

in the xsl atribute onclick i used xsl-vaue-of to create
makeRequest('VALUE INSERTED USING XSL FROM XML'). but ''
was difficult inserting.

There are ways around that:

<xsl:attribute
name="onclick">
<xsl:text>makeRequest('</xsl:text>
<xsl:value-of select="$value"/>
<xsl:text>');</xsl:text>
</xsl:attribute>

or:

<xsl:attribute
name="onclick">
<xsl:value-of
select="
concat
(
concat
(
&quot;makeRequest('&quot;,
$value
),
&quot;');&quot;
)
"/>
</xsl:attribute>
 
M

moralbarometer

Hallo,
I tried your method and it worked well. however, i tried this before
reading your reply:


<a id="1" href="#" onclick="makeRequest('{link}')"> test</a>

really there are many ways going around it.

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top