1

I'm looking to do a very simple insert of javascript in XSLT. e.g.

<xsl:variable name="comboname" select="@name" />
        <script type="text/javascript">
          var z{$comboname} = {$comboname};
        </script>

However, when I run the transform it gives:

<script type="text/javascript">
              var z{$comboname} = {$comboname};
            </script>

I've debugged and $comboname has the correct value...but how do I get that into my javascript?

MANY thanks!

1

1 Answer 1

4
var z<xsl:value-of select="{$comboname}"/>=<xsl:value-of select="{$comboname}"/>;
Sign up to request clarification or add additional context in comments.

2 Comments

THANK YOU! So simple and yet I couldn't find this anywhere online :)
The reason you couldn't find it is that the solution (and the problem) have nothing to do with Javascript. The way you create variable text in XSLT is to use xsl:value-of for element content, and curly braces for attribute content, the fact that the text is Javascript is quite irrelevant.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.