I'm using a form that use the following script to calculate the item price including VAT:
function calculateTotaleIVA() {
var tot = document.getElementById('totale').value;
document.getElementById('totale_prodotto').value = Math.round(tot*121)/100;
totale_prodotto.value = document.getElementById('totale_prodotto').value.replace(".", ",");
totale.value = document.getElementById('totale').value.replace(".", ",");
}
This function works fine but I have a questions. Some times the result is like this:
46,4
I want to see at screen two digits after point decimal like this:
46,40
How can I fix the above function to solve it?
Thanks in advance.
Use toFixed
(Math.round(tot*121)/100).toFixed(2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With