I'm using a script to generate a new row with value each time, those values goes to a table as an input All what I want is a button to sum all values in those inputs in one input.
Total input id is valueall
This is the code I have used:
function updateSubTotal() {
var table = document.getElementById("empTable");
for (var i = 0, row; row = table.rows[i]; i++) {
for (var cell; cell = row.cells[1];){
var inp = cell.children[0];
}
}
document.getElementById("valueall").value = inp.value;
}
That code works fine when I put it under var inp = cell.children[0]; but it keeps repeating the same row value as loop.
Here's the table:
<form>
<table id="empTable">
<tr>
<td>Products in the invoice</td>
</tr>
</table>
</form>