I'm a bit stuck in my coding. I have a rating system, and I need to show x numbers of stars depending of total score.
I have the total score but when I try to show starts noting is show if the total scores is a decimal number.
I have this on top: <xsl:decimal-format name="euro" decimal-separator="," grouping-separator="."/> and the is the total score variable: <xsl:variable name="ScoreValue" select="format-number($TotalSingleScore div $SuperTotal *10,'#.###,##','euro')"/>
The format-number() function returns a formatted string, which you shouldn't use in comparisons (you're comparing a string with a number). You should only use it to display the value(s).
Compare decimal numbers
Hi.
I'm a bit stuck in my coding.
I have a rating system, and I need to show x numbers of stars depending of total score.
I have the total score but when I try to show starts noting is show if the total scores is a decimal number.
I have this on top:
<xsl:decimal-format name="euro" decimal-separator="," grouping-separator="."/>
and the is the total score variable:
<xsl:variable name="ScoreValue" select="format-number($TotalSingleScore div $SuperTotal *10,'#.###,##','euro')"/>
and here is the thing I try to do:
<xsl:if test="$ScoreValue >= 7.34 and $ScoreValue <= 9.99">
<img src="/img/greenstar.png" class="ratestar"/>
<img src="/img/greenstar.png" class="ratestar"/>
<img src="/img/greenstar.png" class="ratestar"/>
<img src="/img/greenstar.png" class="ratestar"/>
</xsl:if>
No stars is shown if $ScoreValue output is 5,6 only if the $ScoreValue is like 5 or 6 ...
Can anyone help me out here.
/Palle
Hi Palle,
The format-number() function returns a formatted string, which you shouldn't use in comparisons (you're comparing a string with a number). You should only use it to display the value(s).
Try something like this instead:
/Chriztian
Hi Chriztian.
It works :)
Thanks for your reply.
is working on a reply...