Copied to clipboard

Flag this post as spam?

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


  • Bobby 43 posts 63 karma points
    Oct 27, 2011 @ 12:31
    Bobby
    0

    Show the Value in KiloMeters or miles based on condition

    Hi,

    I am not sure whether i am posting the topic in correct section.

    Here is my situation. i have a property in the document which is of type number and the content is allowed to enter the Value. This value holds the information of the distance.Based on the Location(for ex; USA/India) the value should be displayed on the Webpage as Miles/KiloMeters.

    Ex: I specify 450 for the property value and select the location as India and on the webpage i need to display as 450 KM. If i select the Location as USA it should display as 450 Miles

    Any help would be appreciated.

    Thanks

    Bobby 

  • Dan Okkels Brendstrup 101 posts 197 karma points
    Oct 28, 2011 @ 13:09
    Dan Okkels Brendstrup
    1

    Won't you also want to do a conversion between miles and kilometers? 450 km is ~280 miles, and 450 miles is ~724 km...

    Is the Location set via a dropdown control or something similar? In that case, you could do something like this:

    <xsl:template match="Distance">
      <xsl:variable name="unit">
        <xsl:choose>
          <xsl:when test="location = 'USA'">miles</xsl:when>
          <xsl:otherwise>kilometers</xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
      <xsl:value-of select="concat(measure, ' ', $unit)"/>
    </xsl:template>
  • 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