0

I have this script which gives me number results like "4236.13741375". How can I get an output with a price format? Ex. "4,236.14" instead of "4236.13741375".

<script type='text/javascript' >
function startCalc(){
      interval = setInterval("calc()",1);
}
function calc(){

// ITEM 1 START 
d_r1_qte = document.autoSumForm?.d_r1_qte?.value ?? 0;
d_r1_unitprice = document.autoSumForm?.d_r1_unitprice?.value ?? 0;
d_r1_price = d_r1_qte * d_r1_unitprice;
document.autoSumForm.d_r1_price.value =  d_r1_price;
// ITEM 1 END

// INVOICE FOOTER START 
d_rtotal = d_r1_price;

d_rtotaltx = ((d_rtotal/100)*15)+d_rtotal; 
d_fadmin = (d_rtotaltx/100)*3;
document.autoSumForm.d_fadmin.value = d_fadmin;
d_stotal = d_fadmin + d_rtotal;
document.autoSumForm.d_stotal.value = d_stotal;
d_tps = (d_stotal/100)*5;
document.autoSumForm.d_tps.value = d_tps;
d_tvq = (d_stotal/100)*9.975;
document.autoSumForm.d_tvq.value = d_tvq;
d_total = d_stotal + d_tps + d_tvq;
document.autoSumForm.d_total.value =  d_total;
// INVOICE FOOTER END
}
FMR
  • 33
  • 4
  • check this answer: https://stackoverflow.com/questions/149055/how-to-format-numbers-as-currency-string – Marik Ishtar Jun 26 '20 at 00:18
  • 1
    Does this answer your question? [How to format numbers as currency string?](https://stackoverflow.com/questions/149055/how-to-format-numbers-as-currency-string) – Marik Ishtar Jun 26 '20 at 00:18

0 Answers0