This topic is locked

Help needed with decimal rounding

10/28/2008 5:33:53 AM
PHPRunner General questions
L
Lisa2006 author

Hi Forum,
I have the following javascript added at the end of my ADD page via Visual Editor:
{literal}

var x = document.editform.value_jobcost;

x.onchange = x.onkeyup = function() {

var jobcost = document.editform.value_jobcost.value;

var vat = document.editform.value_vat.value;

var gross = document.editform.value_gross.value;

document.editform.value_vat.value = Number(parseFloat(jobcost) 0.175).toFixed(2);

document.editform.value_gross.value = Number(parseFloat(jobcost) + parseFloat(jobcost)
0.175).toFixed(2);

document.forms.editform.value_gross.disabled=true;

document.forms.editform.value_vat.disabled=true;

}

{/literal}
Here's the problem:__

When I enter the following data, it returns the following results:
jobcost=7.00, vat=1.22, gross=8.23

jobcost=10.50, vat=1.84, gross=12.34

jobcost=1.00, vat=0.18, gross=1.18
As you can see the result highlighted in red is not rounding to 1.23
Your help and Support would be much appreciated.
Lisa