This topic is locked

Too many decimal Places

10/15/2008 3:15:20 AM
PHPRunner General questions
S
swanside author

Hi,
I have this code

<script>

document.forms.editform.value_Amount.onchange=function()

{

if(document.forms.editform.value_Vatable.checked==true)

{

document.forms.editform.value_AUDIT_VAT.value=document.forms.editform.value_Amou

nt.value/47*7;

document.forms.editform.value_VAT_PAYMENTS.value=document.forms.editform.value_A

mount.value/47*7;

document.forms.editform.value_NET.value=document.forms.editform.value_Amount.val

ue-document.forms.editform.value_AUDIT_VAT.value;

}

else

{

document.forms.editform.value_NET.value=document.forms.editform.value_Amount.val

ue;

}

}

</SCRIPT>


It displays a value similar to 123.76849347 where I want it to display 123.77
I have searched around and found this

AUDIT_VAT = AUDIT_VAT.toFixed(2);



But it wont do any difference.

Any ideas please?
Ta
Paul.

S
swanside author 10/15/2008

Paul,

please check following links:

http://www.w3schools.com/jsref/jsref_obj_math.asp

http://www.mediacollege.com/internet/javas...mber/round.html


Thanks for that, but it may aswell be in double dutch to me. I see the formulars but, dont know where they have to go.
Oh well.
Will keep trying
Thanks

S
swanside author 10/16/2008

I,v tried this

document.forms.editform.value_AUDIT_VAT.value=document.forms.editform.value_Amou

nt.value/47*7;

document.write(Math.round(AUDIT_VAT));


but it doesnt work,
ANy pointers please?
Ta

Paul

J
Jane 10/16/2008

Here is just a sample:

document.forms.editform.value_AUDIT_VAT.value=Math.round(document.forms.editform

.value_Amount.value/(477100))/100;

S
swanside author 10/16/2008

Here is just a sample:



Thanks Jane,
Just been printing out that topic from W3 schools.
Paul.

S
swanside author 10/16/2008



Thanks Jane,
Just been printing out that topic from W3 schools.
Paul.


Great. Got it now by using this

document.forms.editform.value_AUDIT_VAT.value=Math.round(document.forms.editform.value_Amount.value/47*(7*100))/100;


Thanks for the pointers