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]
[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]