mq.hidayat
New Member
I have a jsfiddle here.In the fiddle there is a number of mark textboxes. Type a number in the text box and keep clicking on the add question button. You will see that the total marks remaining equals \[code\]10\[/code\] but it doesn't change. The number of marks remaining should change by subtracting each number in the appended row.For example, if total marks remaining is \[code\]10\[/code\] and you append four rows, each row containing marks of \[code\]1\[/code\], then total marks remaining should be \[code\]6\[/code\]. (\[code\]10 - 4 = 6\[/code\].) But why is it not changing the number of marks remaining?This is the function where it performs the calculation:\[code\]function calculateTotal(){ var totalweight = totalmarks; $("#qandatbl td.weight input").each(function (i, elm){ totalweight = totalweight - Number($(elm).val(), 10); }); $("#total-weight").text(totalweight);}\[/code\]