Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peter Alcock 113 posts 176 karma points
    Dec 10, 2016 @ 11:15
    Peter Alcock
    0

    Jquery within XSLT

    Hi all,

    I am using XSLT to build a quote builder, i need to be able to identify if an input has a 'greater than' value and struggling to get it working within an XSLT. I have tried using CDATA which doesn't seem to work and a bunch of other things!

    I know it would be better to have a seperate js file however i need the js to use xslt variables as seen in example below.

    can anyone help!?!?!

    The below '==' needs to change to a '>' greater than like !> or >

    if (totalHeight == 1100){
        var ppm = <xsl:value-of select="$bLwPPM"/>;<!--lightweight cost up to 1100, will change to greater than in .js-->
        }
        else{
        var ppm = <xsl:value-of select="$sLwPPM"/>;<!--lightweight cost up to 600-->
        }
    
  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Dec 11, 2016 @ 21:56
    Chriztian Steinmeier
    0

    Hi Peter,

    You should be able to use the disable-output-escaping attribute for this:

    <xsl:text disable-output-escaping="yes"><![CDATA[
    if (totalHeight > 1100) {
        var ppm = ]]></xsl:text><xsl:value-of select="$bLwPPM" />;<!--lightweight cost up to 1100, will change to greater than in .js-->
    <xsl:text disable-output-escaping="yes"><![CDATA[
    } else {
        var ppm = ]]></xsl:text><xsl:value-of select="$sLwPPM" />;<!--lightweight cost up to 600-->
    }
    

    Another way would be to only output the two variable values as global JS variables (that your external script could read), or if it makes sense - put them on some element as data-attributes?

    Hope that helps,

    /Chriztian

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies