andrewsmd

msg:4376794 | 9:49 pm on Oct 19, 2011 (gmt 0) |
Figured out the variable thing <xsl:variable name="divId"> <xsl:choose> <xsl:when test="number($milesVar) >= 3000000 ">threeMillion</xsl:when> <xsl:when test="number($milesVar) >= 2000000">twoMillion</xsl:when> <xsl:otherwise>oneMillion</xsl:otherwise> </xsl:choose> </xsl:variable> Now how do I add all of those select values and output a javascript function call?
|
httpwebwitch

msg:4378648 | 1:38 pm on Oct 24, 2011 (gmt 0) |
you can make XSLT render a <script> element, and everything in it. Dont forget to use <![CDATA[ ]]> nodes so your script doesn't get mangled. Another option is to output those XSL values into some hidden <input> elements, then write your javascript so it executes on pageload (or domready) and reads those values from the DOM. That way will be far less complicated & easier to code up.
|
andrewsmd

msg:4378675 | 3:01 pm on Oct 24, 2011 (gmt 0) |
This is what I ended up with <xsl:template match="udt:Data" mode="list"> <tr class="Normal"> <td> <xsl:variable name="milesVar" select="udt:Miles" /> <xsl:variable name="divId"> <xsl:choose> <xsl:when test="number($milesVar) >= 3000000 ">threeMillion</xsl:when> <xsl:when test="number($milesVar) >= 2000000">twoMillion</xsl:when> <xsl:otherwise>oneMillion</xsl:otherwise> </xsl:choose> </xsl:variable> <script type="text/javascript"> <xsl:text>millionMiles('</xsl:text><xsl:call-template name="EditLink" /><xsl:value-of select="udt:Name" disable-output-escaping="yes" /><br /> <xsl:value-of select="udt:Image" disable-output-escaping="yes" /><br /> <xsl:text>Driving since </xsl:text><xsl:value-of select="udt:Driving_x0020_Since" disable-output-escaping="yes" /><br /> <xsl:text>He has over </xsl:text><xsl:value-of select="udt:Miles" disable-output-escaping="yes" /> accident free miles.<br /><br /> <xsl:text>', "</xsl:text><xsl:value-of select="$divId" />");<xsl:text></xsl:text> </script> </td> </tr> </xsl:template>
|
|