There are lots of drama in the code. I'll try to point out as much as possible
1. The posted markup seem a bit off, like missing closing table tag
</table>
, upper case
<SCRIPT>
, then
<pre>
tag in between the markup, etc... I'm assuming that not an issue at your end
2. I would suggest to call the
getSum
on
debitT
textbox click, currently the code have
onkeyup="sum()"
. I don't see
sum()
method anyway in the code
3. If you look at the code closely, the code is appending a
textbox
into the table cell, therefore, the code can't just go and sum up the value in the cell. below is an example on how to access the
textbox
value.
let innerCell = table.rows[i].cells[1];
let textBox = innerCell.getElementsByTagName("input")[0];
sumVal = sumVal + parseInt(textBox.value);
4. for textbox, use the .
value
property instead of .
innerHTML
5. pay attention to the loop
Here is an example:
CP_row_sum - JSFiddle[
^]