We are working on a Travel Reimbursement form using Forms 9.2. We have section called Meals that looks like the following:
The "Less than 12 hours" option has a value of 0. The "Over 12 hours" option has a value of 35. The Breakfast, Lunch, and Dinner options each have their own values as well. I have been using the following code to try and calculate the "Hours" value with any or all of the "Meals" values that are selected, but I can only get it to grab the "Hours" value.
$(document).on('blur change', '.mealsum input:checked', summealtotal); function summealtotal() { var s = 0; $('.mealsum input:checked').each(function () { s += parseNumber($(this).val()); }); $('.mealtotal input').val(s); } function parseNumber(n) { var f = parseFloat(n); //Convert to float number. return isNaN(f) ? 0 : f; //treat invalid input as 0; }
The Meals field and the Hours field both have the mealsum CSS class assigned to the. The 1 Day Meal Total field has the mealtotal CSS class assigned.
Any ideas of what needs to be changed?