diff --git a/templates/_js.tpl b/templates/_js.tpl index 5508ae6..301ddae 100644 --- a/templates/_js.tpl +++ b/templates/_js.tpl @@ -4,10 +4,14 @@ function updateSum(){ var total = 0; e = document.querySelectorAll('input[name="prix[]"]'); - e.forEach( function sum(item, index){ - total = total + Number(item.value); + e.forEach((item) => { + if (!item.value) { + return; + } + + total += g.getMoneyAsInt(item.value); }); - document.getElementById('total').innerHTML = total.toFixed(2); + document.getElementById('total').innerHTML = g.formatMoney(total); } (function () { @@ -21,6 +25,7 @@ this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode); updateSum(); }; + newdiv.getElementsByTagName('input')[0].onkeyup = updateSum; document.getElementById('Lines').appendChild(newdiv); } plus();