Copied to clipboard

Flag this post as spam?

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


  • CodeMaster2008 151 posts 184 karma points
    Apr 02, 2010 @ 14:58
    CodeMaster2008
    0

    Passing a boolean parameter to a javascript function

    Hi, this is my first time with xslt and i hope somebody help me figure this one out.
    I created a macro with a parameter called (alias) "showNavigation", type: bool.

    The idea is to pass this parameter to a javascript function which expect a value of 'true' or 'false' but I'm getting a numeric value instead.
    Here is what I'm doing:

    <script type="text/javascript">  
     $(document).ready(function(){ $('#features').jshowoff(controls: <xsl:value-of select="/macro/showNavigation"/> ); });
    </script>
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 02, 2010 @ 15:20
    Jan Skovgaard
    1

    Hi

    I think you can solve this by making a variable, where you get the correct value and then call it in your function. So the code would look something like this.

    <xsl:variable name="showNavigation">
    <xsl:choose>
    <xsl:when test="/macro/showNavigation = '1'"><xsl:text>true</xsl:text></xsl:when>
    <xsl:otherwise><xsl:text>false</xsl:text></xsl:otherwise>
    </xsl:choose>
    </xsl:variable>

    and then in your script you just write <xsl:value-of select="$showNavigation" />

    Hope this helps

    /Jan

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Apr 02, 2010 @ 15:25
    Chriztian Steinmeier
    2

    Hi CodeMaster2008

    You can do the following: 

    <xsl:value-of select="string(boolean(/macro/showNavigation))" />

    /Chriztian

  • CodeMaster2008 151 posts 184 karma points
    Apr 02, 2010 @ 16:38
    CodeMaster2008
    0

    i was about to look for how to make an if statment and Jan already gave me the answer. got 2 for the price of one :-)
    thanks a lot guys.

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Apr 02, 2010 @ 16:57
    Chriztian Steinmeier
    0

    You're welcome - as you've already found out by now, the Umbraco community is very responsive and friendly :-)

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft