1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
(function (window) {
"use strict";
var document = window.document,
trs = document.getElementsByTagName('tr'),
tds,
iTr,
sommeAuto = function (td1, td2, tds) {
td1.addEventListener("blur", function () {
tds.innerText = parseInt(td1.innerText, 10) + parseInt(td2.innerText, 10);
});
td2.addEventListener("blur", function () {
tds.innerText = parseInt(td1.innerText, 10) + parseInt(td2.innerText, 10);
});
};
for (iTr = 1; iTr < trs.length; iTr += 1) {
tds = trs[iTr].getElementsByTagName('td');
sommeAuto(tds[1], tds[2], tds[3]);
}
}(this)); |
Partager