Getallen worden ongewenst afgerond

Status
Niet open voor verdere reacties.

indahhome

Nieuwe gebruiker
Lid geworden
12 aug 2011
Berichten
2
Ik gebruik voor een bestelmodule voor mijn site een javascript om het subtotaal en totaal van een bestelling uit te rekenen. Maar het totaal wordt altijd afgerond op ..,00 maar ik snap niet waarom. Iemand enig idee? Alvast bedankt.

[JS] document.getElementById('lblPrice').innerHTML = parseInt(price).toFixed(2).replace(".", ",");
document.getElementById('lblRPrice').innerHTML = parseInt(price).toFixed(2).replace(".", ",");
var subtotal = 0;
if(!isNaN(price)){
subtotal = (parseInt(val) * parseInt(price)).toFixed(2);
document.getElementById('lblSubTotal').innerHTML = subtotal.replace(".", ",");
var btw = (subtotal / 100) * 19;


document.getElementById('lblBTW').innerHTML = btw.toFixed(2).replace(".", ",");

var total = parseInt(subtotal)+parseInt(btw)+20;
total = parseInt(total).toFixed(2).replace(".", ",");
document.getElementById('lblTotal').innerHTML = total;
}else{
document.getElementById('lblTotal').innerHTML = "Op aanvraag";
document.getElementById('lblSubTotal').innerHTML = "Op aanvraag";
}[/JS]
 
Alle parseInt() vervangen door parseFloat() en dan nog eens kijken
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan