1

I have a loop that runs perfectly. The toFix() method trims to the correct decimal place but does not round. Why would that be?

I'm using ColdFusion as well with it to fill in some variables. Thanks

document.getElementById('flowinput#forminputdata#').value=(parseFloat(velocity#forminputdata#) * parseFloat(distance#forminputdata#) * parseFloat(depth#forminputdata#)).toFixed(4); 
rrk
  • 15,677
  • 4
  • 29
  • 45
Jdav
  • 13
  • 4
  • 2
    Possible duplicate of [Javascript toFixed Not Rounding](https://stackoverflow.com/questions/10015027/javascript-tofixed-not-rounding) – devlin carnate Nov 14 '18 at 19:36

1 Answers1

4

toFixed() takes the number, converts it to a string, and returns the given amount of decimal places. In order to round the number, you'd want to use toPrecision().

Here is the Mozilla Documentation on that function.

Ryan
  • 481
  • 2
  • 10