Forums: [SOLVED] formatting calculated values - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

[SOLVED] formatting calculated values Rate Topic: -----

#1 User is offline   Michael Fiil 

  • Member
  • PipPip
  • Group: Members
  • Posts: 22
  • Joined: 06-December 17

Posted 16 January 2018 - 03:22 PM

Hi Experts,

i am having a problem with values calculated on the fly!
In Javascript On load (add page) i calculate some values ex.

ctrlfscrap.setValue(((Number(ctrlfnetto.getValue()) * 0.40) / 36) * Number(ctrlfleasperiode.getValue()));


After calculation the value shown are ex. 60456.456789 - how do i format the value to 60456.46 ??

Thanks in advance

Michael
0

#2 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 16000
  • Joined: 03-February 03

Posted 16 January 2018 - 08:20 PM

You can use Javascript's toFixed() function for this purpose.

var n = ((Number(ctrlfnetto.getValue()) * 0.40) / 36) * Number(ctrlfleasperiode.getValue());
n = Number(n).toFixed(2);
ctrlfscrap.setValue(n);


More info:
https://developer.mo.../Number/toFixed
Best regards,
Sergey Kornilov
0

#3 User is offline   Michael Fiil 

  • Member
  • PipPip
  • Group: Members
  • Posts: 22
  • Joined: 06-December 17

Posted 17 January 2018 - 10:19 AM

Perfect Sergey - thank you
0

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked