views:

1005

answers:

1

How would I grab an XSLT variable and use it to set a javascript variable?

I'm working on a bit of AJAX and in order to make it work to the fullest I would like to be able to grab XSLT variables and use those to set the default values of some javascript variables that I'll then be manipulating with jQuery.

A: 

Stick something like the following in your XSLT part that outputs the JavaScript.

<xsl:variable name="myvar" select="'red'">
<xsl:text>myobj="</xsl:text><xsl:value-of select="$myvar"><xsl:text>"</xsl:text>
Mark Schultheiss