I want this form to take information from the Expenses table based on the program selected, such as Mileage Reimbursement (this would be calculated with javascript), the Per Diem amount, and total. Then, the Reimbursement by Program table would dynamically create rows based on programs selected in the Expenses table. It would also dynamically fill in the mileage reimbursement, per diem, and total all per program. Here is the Expense table, Reimbursement by Program table, and code. I basically need help with the javascript coding to get this to work. Thanks!
$(document).ready(function () { $('.amount').on('blur', 'input', 'change', sumtotal); $('.cf-table-block').on('blur', 'input', 'change', sumtotal); $('.totalMiles').on('blur', 'input', 'change', sumtotal); $('.regMiles').on('blur', 'input', 'change', sumtotal); $('.filledField').on('blur', 'input', 'change', sumtotal); $(this).find('.totalReim input').change(sumtotal); function sumtotal() { var sum = 0; var milesRe = 0; //mileage reim without fixed decimal var n = 0; //use to fix 2 decimal places var o = 0; //total without fixed decimal var p = 0; //use to fix 2 decimal places var q = $(this).find('.filledField input').val(); var hdMiles = 0; //housing development miles var test = 0; $('.cf-table-block tbody tr').each(function () { var s = 0; //parsed per diem var totM = 0; //parsed total mileage var regM = 0; //parsed regular commute s = parseNumber($(this).find('.amount input').val()); totM = parseNumber($(this).find('.totalMiles input').val()); regM = parseNumber($(this).find('.regMiles input').val()); milesRe += (totM - regM) * .54; n = milesRe.toFixed(2); sum += s; o = sum + milesRe; p = o.toFixed(2); $('#q30 input').attr("readonly", true); $('#q15 input').attr("readonly", true); }); //end of .cf-table-block $('#q30 input').val(n); $('#q15 input').val(p); } //end of function function parseNumber(n) { var f = parseFloat(n); //Convert to float number. return isNaN(f) ? 0 : f; //treat invalid input as 0; } });