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

toFixed() help

Avatar

Level 2

Hi all,

I have the following code and it seems to be breaking after the .toFixed().  The first message box will display a number but the second message box won't display anything at all.  Wondering if toFixed() doesn't work because labelvalue contains a string?


labelValue = String(monthObj.rawValue - lastMonthEle.rawValue);
   
xfa.host.messageBox(labelValue);
            LabelRounded = labelValue.toFixed(2);
xfa.host.messageBox(LabelRounded);

3 Replies

Avatar

Level 4

Hi,

toFixed does not work on String Values.

Regards--

Chalukya.

Avatar

Level 4

you can convert your textField data to Numeric data and then use toFixed();

var NumericValue = parseFloat( this.rawValue );
app.alert(NumericValue.toFixed());
this.rawValue = NumericValue.toFixed() ;

this.rawValue is my textField data.

Regards--

Chalukya