I am trying to find a way to add two columns on a row where one of them is already a total of 2 columns. In the picture attached I need to add: Day total and Previous total to fill in the new month total. I use the following code to fill in the day total column:
$(document).ready(function () {
$('.cf-table-block').on('blur', 'input', sumtotal);
function sumtotal() {
var sum = 0;
$('.cf-table-block tbody tr').each(function () {
var s = 0;
$(this).find('.meal input').each(function () {
s += parseNumber($(this).val());
});
$(this).find('.subtotal input').val(s);
sum += s;
});
$('.total input').val(sum);
}
function parseNumber(n) {
var f = parseFloat(n); //Convert to float number.
return isNaN(f) ? 0 : f; //treat invalid input as 0;
}
});
What do I need to add to make the rest of the calculations happen? The day total has a class of: subtotal, Previous total is class: prev_tot, and New month total is class: new_tot