0
function addTotal(){


var txtTotal = document.getElementById('txtTotal').value; 

var txtGrandTotal = document.getElementById('txtGrandTotal');

txtGrandTotal.value += parseInt(txtTotal);
}


this is delete code 
$(".delete-row").click(function(){
$("table tbody").find('input[name="record"]').each(function(){
if($(this).is(":checked")){
$(this).parents("tr").remove();
}
});
});

if the user deletes the row then the values from the Grand Total Should decrease. anything I should do any body

how to add values to the "Grand Total" to the Total input box Total is the dynamically created table data and I want to add values to that "Grand Total input box" but values are appending not the adding and also I have added an enter image description hereimage of the screen or output. Thanks in advance.

2
  • no bro same result I am getting. Commented Nov 3, 2017 at 8:23
  • yes, I have tried. Commented Nov 3, 2017 at 8:28

1 Answer 1

3

Instead of

txtGrandTotal.value += parseInt(txtTotal);

as txtGrandTotal.value isn't converted to int, it is string

so you should do:

if (!txtGrandTotal.value)
    txtGrandTotal.value =  parseInt(txtTotal);
else    
    txtGrandTotal.value =  parseInt(txtGrandTotal.value) + parseInt(txtTotal);
Sign up to request clarification or add additional context in comments.

2 Comments

I am getting NaN(not a number) In grand total
in the same way if I delete the row the value from the grand total should decrease.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.