Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Formatting number: a percentage with only one decimal

Avatar

Level 2

I dont know how to format number to obtian a number that is a  percentage with only one decimal, e.g. 3,0%

Thanks

0 Replies

Avatar

Level 10

Is there a requirement to enter the number in a particular format? For example, you enter "30" and it should render "3.0%"

Or is the value calculated?

Steve

Avatar

Level 7

The pattern would be:

num{zzzz9.z%}

But as Steve asked, if the number will be put in as a whole number (e.g. - 30.1 = 30.1%) then you'll need a script in the exit event:

this.rawValue = (this.rawValue / 100);

Avatar

Level 2

You can format number decimal places in JavaScript using .toFixed() e.g.

var testNumber = 3.0123;
this.rawValue = testNumber.toFixed(1);     // result is 3.0

Ben Walsh

http://www.avoka.com