Fix calcul de la somme des éléments en direct
This commit is contained in:
parent
364c7065fc
commit
b644eb34bf
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue