Page 1 of 1

how to set a javascript variable in an xsl variable.

Posted: Thu Dec 20, 2007 5:51 pm
by mebimathew
Hi
can you please tell me how to set a javascript variable in an xsl variable.
i have done like this
<xsl:variable name="hello">
<script language="javascript">
var i =0;
</script>
<script language="javascript">
alert('<xsl:value-of select="$hello"/>');
</script>
</xsl:variable>

i know this wont work..can you please tell me how to set a javascript variable in an xsl variable.

Thanks in advance

Posted: Thu Dec 20, 2007 6:03 pm
by Radu
Hi,

I am not exactly sure what you are trying to accomplish.
You are declaring a variable and in it you are trying to refer to the same variable.
This can't be right.

Is this something more like what you want?

Code: Select all


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<xsl:variable name="hello" select="1"/>
<script language="javascript">
var i =<xsl:value-of select="$hello"/>;
</script>
<script language="javascript">
alert('<xsl:value-of select="$hello"/>');
</script>
</xsl:template>
</xsl:stylesheet>
If not, can you clarify more what you are trying to accomplish?

Regards,
Radu