Jump to content

Recommended Posts

Hey guys i have tried a few combinations with no luck...

 

i have a tax cal for my invoice form but i need to round out the total not to have 1.23445

 

 

i have tried

 

 
 document.formname.Total.value = formname.Total.value.round (text1+text2+text3+text4+text5)* 0.14975 + (text1+text2+text3+text4+text5);
 
 document.formname.Total.value = Total.round (text1+text2+text3+text4+text5)* 0.14975 + (text1+text2+text3+text4+text5);
 
 
...
 
any clue how?
 
Link to comment
https://forums.phpfreaks.com/topic/284205-round-total/
Share on other sites

So i have an invoice and it calculates tax.works fine but i need to round the decimals.so i don't get 12.1234$

 

i have this

 

function calculate(){ 
 
 if(isNaN(document.formname.f1.value) || document.formname.f1.value==""){ 
 var text1 = 0; 
 }else{ 
 var text1 = parseInt(document.formname.f1.value); 
 } 
 
 if(isNaN(document.formname.f2.value) || document.formname.f2.value==""){ 
 var text2 = 0; 
 }else{ 
 var text2 = parseFloat(document.formname.f2.value); 
 } 
 
  if(isNaN(document.formname.f3.value) || document.formname.f3.value==""){ 
 var text3 = 0; 
 }else{ 
 var text3 = parseFloat(document.formname.f3.value); 
 } 
 
  if(isNaN(document.formname.f4.value) || document.formname.f4.value==""){ 
 var text4 = 0; 
 }else{ 
 var text4 = parseFloat(document.formname.f4.value); 
 } 
 
  if(isNaN(document.formname.f5.value) || document.formname.f5.value==""){ 
 var text5 = 0; 
 }else{ 
 var text5 = parseFloat(document.formname.f5.value); 
 } 
 
 
 
 document.formname.Total.value = (text1+text2+text3+text4+text5)* 0.14975 + (text1+text2+text3+text4+text5);
Link to comment
https://forums.phpfreaks.com/topic/284205-round-total/#findComment-1459764
Share on other sites

I see.

 

Try to do it like this, then.

 

function calculate() {

// your code here...

document.formname.Total.value = Math.round((text1+text2+text3+text4+text5)*0.14975+(text1+text2+text3+text4+text5));
That should do the trick. Edited by Irate
Link to comment
https://forums.phpfreaks.com/topic/284205-round-total/#findComment-1459766
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.