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(){
|
function updateSum(){
|
||||||
var total = 0;
|
var total = 0;
|
||||||
e = document.querySelectorAll('input[name="prix[]"]');
|
e = document.querySelectorAll('input[name="prix[]"]');
|
||||||
e.forEach( function sum(item, index){
|
e.forEach((item) => {
|
||||||
total = total + Number(item.value);
|
if (!item.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
total += g.getMoneyAsInt(item.value);
|
||||||
});
|
});
|
||||||
document.getElementById('total').innerHTML = total.toFixed(2);
|
document.getElementById('total').innerHTML = g.formatMoney(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
@ -21,6 +25,7 @@
|
|||||||
this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
|
this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
|
||||||
updateSum();
|
updateSum();
|
||||||
};
|
};
|
||||||
|
newdiv.getElementsByTagName('input')[0].onkeyup = updateSum;
|
||||||
document.getElementById('Lines').appendChild(newdiv);
|
document.getElementById('Lines').appendChild(newdiv);
|
||||||
}
|
}
|
||||||
plus();
|
plus();
|
||||||
|
Loading…
Reference in New Issue
Block a user