asked on June 6, 2016
The goal of this form is to first subtotal the values inputted within a collection. Then take that subtotal value and multiply it by a rate value inputted by the user to get the Grand Total.
Collection Subtotal x Rate = Grand Total
$(document).ready(function () { $('.cf-collection-block').on('blur', 'input', sumtotal); function sumtotal() { var sum = 0; $('.cf-collection-block ul').each(function () { var s = 0; $(this).find('.hour input').each(function () { s += parseNumber($(this).val()); }); $(this).find('.subtotal input').val(s); sum += s; }); $(".subtotal input").val(sum); var subtotalPrice = parseNumber($(".subtotal input").val()); var rateAmount = parseNumber($(".rate input").val()); $(".total input").val((subtotalPrice * rateAmount).toFixed(2)); } function parseNumber(n) { var f = parseFloat(n); //Convert to float number. return isNaN(f) ? 0 : f; //treat invalid input as 0; } });
The subtotal values are working correctly but I have not been able to integrate the "Rate" into the equation.
Please let me know if any additional information may be helpful.
Your assistance is appreciated!
Cynthia Stewart
0
0