You are viewing limited content. For full access, please sign in.

Question

Question

rounding issue with number field using javascript

asked on February 5, 2018

Hi All,

 

Hoping this is a quick one, I have a field that is calculating hours worked total for timesheet. I have set the field to be using 2 decimal places:

I have Javascript setup to calculate the hours based on the days selected. But, when the user is selecting 3 days of work for the week, the field is populating a long number as per below:

 

Every other selection, be it 2 days, 4 days etc, calculates 1 decimal point. But, not sure why this field would be doing this? Where should I be looking at the code to make sure it is rounding the field? 

I have tried to add (roundDecimal) on the field itself, but it stops calculating the times selected on the dates. 

I know I am missing something in the code, just cannot get my hand on it!

 

Any feedback would be kindly appreciated, 

 

Thank you in advance,

Ziad

 

 

0 0

Replies

replied on February 5, 2018 • Show version history

Hi All,

 

Managed to get this resolved offline. 

By adding the following .toFixed(2) on the actual field in question, it resolved the issue. 

i.e $('#q"FieldNumber" input').val("Your Variable).toFixed(2));

 

 

Thanks guys, 

Ziad

5 0
You are not allowed to follow up in this post.

Sign in to reply to this post.