Fustigador
Fustigador

Reputation: 6469

How to format a text in html

I have a .gsp, that displays a number in the page. The problem is, i receive that number (from the server) with decimals, even if the decimal is 0. I would like to "if the last character in this string is 0, erase from the dot till the end"

Any idea? if possible, without touching the server side.

Thank you.

Upvotes: 0

Views: 206

Answers (3)

Lauri Piispanen
Lauri Piispanen

Reputation: 2097

You're better off treating numbers as numbers (parsing them if needed), and then using format tags that come bundled with Grails. In this case g:formatNumber would be appropriate.

Upvotes: 2

srjit
srjit

Reputation: 526

on your .gsp page do a g:if test at the place where you display the number. Check if the last character is 0, if it is, do a toString() on the number, split by the '.' and show the the string at 0th index.

Upvotes: 0

Billy Moat
Billy Moat

Reputation: 21050

You can do this with javascript/jQuery but not with CSS.

Upvotes: 0

Related Questions