I have a button of which voids the last tr in a table. Each time it does this the total is worked out again using function mainTotalCalc().
The total is worked out through using .each and classes.
The issue arises when i get to one last row remaining. The total will remain as the last total. It never reaches 0.00
Now i think i can see why, as the JQ each considers the last total in the variable.
I am stuck on how to make the last remaining row be voided whilst the total calculates correctly.
The Fiddle (But parseFloat does not seem to work here)
The JS/JQ
function mainTotalCalc() {
var activetableID = $("li.till_table_button.active").attr('id');
// alert(activetableID);
var tablenumber = $("#"+activetableID).data("tableref");
// alert(tablenumber); //testing
var newtotal=0,total=0;
$('.till__tablepanel_table_'+tablenumber+'_row__totalprice').each( function(i) {
var number = $(this).text();
//alert(content);
//num = parseInt(number);
num = parseFloat(number);
newtotal += num;
// alert(number); //testing
totalpriceDecimal = newtotal.toFixed(2);
$('#till__totalpanel_table_'+tablenumber+'_price').html(newtotal.toFixed(2));
// alert(totalpriceDecimal);
i++;
});
}
Before Last Void

After Last Void (Total remains as 1.00 and shouldn't be)

mainTotalCalc()to be fired?tr:lastremoval. The removal works perfectly, and adding rows calculates perfectly. Its just when voiding them, the last one has an issue. I think its something to do with the +=, but i am not sure.