471,086 Members | 809 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,086 software developers and data experts.

calling javascript function in xsl

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

Oct 11 '06 #1
2 10089

moralbarometer wrote:
<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>

--
Pavel Lepin

Oct 11 '06 #2
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


p.*****@ctncorp.com wrote:
moralbarometer wrote:
<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>

--
Pavel Lepin
Oct 11 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Krishna | last post: by
6 posts views Thread by szabelin | last post: by
1 post views Thread by Markusek Peter | last post: by
4 posts views Thread by Martin Feuersteiner | last post: by
reply views Thread by kike | last post: by
1 post views Thread by Larry | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.