I have written a simple conditional Javascript in a Narrative view so that it fetch columns from database and represent the data .
I have used the sample EMP table and the intension is to represent the row for Managers in Green and others in Orange like below :
The narrative code to drive this as below :
<script type=”text/javascript”>
if(‘@3’==’MANAGER’)
{
document.write(“<font color=green><b> @1 is Manager having salary @4 <br> </b></font>”)
}
else
{
document.write(“<font color=orange><b> @1 is Not Manager having salary @4 <br> </b></font>”)
}
</script>
What if I wanted to format @4 as a number with commas’s. I’ve tried a functions like the found here http://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-money-in-javascript
using a reference like this in my narrative view
(@16).toMoney()
Do I have my syntax wrong or is this not possible…
Thanks
Hi Bill ,
Sorry for getting back so late. Instead of using the function to format the data to number in your narrative you can directly cast the value in the expression in criteria of the column like CAST ( as Number) .
Hope that helps .
Regards,
Debashis
Hi debasish,
I have sales growth in a field, if its positive i need to display up arrow sign and if its negative i need to display down arrow sign. I tried with the if else structure u gave here, but its not working. can you please help
Regards:
Niladri
You should be . Can you reply with the code what you are trying to achieve? You need to have the HTML reference to your email or using fmap .
Thanks.