Is there any attribute to round off the decimal value

amaradiswamy
Kilo Sage

Hi All,

I have created a field(String data type) and populating average value to that field. The process is fine but its is populating upto 8 decimal points because the field is string type. is there any available attribute(for the variables) to round off the average value and populate the value with only two decimal points(a.bc).

Thanks & Regards,

Swamy

1 ACCEPTED SOLUTION

Naveen Kumar J
Tera Expert

Please try x = x.toFixed(2);


View solution in original post

5 REPLIES 5

Hi Pradeep,



The problem here is that i have defined field data type as string instead of decimal value. If i change the data type now then the data stored in the field will be erased. That's why is there any way to round off the average value to 2 decimal places for string data type fields.



Thanks & Regards,


Swamy


Hi,



Thanks for the update. Try this with the client script.


var val = g_form.getValue('u_sal');


var dec = Math.round(val * 100) / 100;


Naveen Kumar J
Tera Expert

Please try x = x.toFixed(2);