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.

1 Answer 1

3

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

<xsl:variable name="myvar" select="'red'" />
<xsl:text>var myobj="</xsl:text><xsl:value-of select="$myvar"></xsl:value-of><xsl:text>"</xsl:text>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.