I have a form where a user inputs and start and finish time to give a total of hours then i want to multiply that total with a rate and have it subtotal per row.
So far i have used some JavaScript to do the time calculations and give me the total hours, but i don't know how to multiply the total with the rate.
$(document).ready(function () { $('.cf-table-block').on('blur', 'input', sumtotal); $(document).on('click', '.form-del-field', sumtotal); function sumtotal() { var stime = 0; var ftime = 0; var total = 0; var subtotal = 0; $('.cf-table-block tbody tr').each(function () { stime = moment($(this).find('.stime input').val(), 'HHmm'); ftime = moment($(this).find('.ftime input').val(), 'HHmm'); subtotal = stime.diff(ftime, 'Hours', true); $(this).find('.total input').val(subtotal.toFixed(2)); total += subtotal; }); $('.Grandtotal input').val(total.toFixed(2)); } function parseNumber(n) { var f = parseFloat(n); //Convert to float number. return isNaN(f) ? 0 : f; //treat invalid input as 0; } });
There is the option for a Total outside the table but i'm not going to use that part.
The rate is populated from a database lookup.
I just need to multiply the total hours with the rate
Can someone help please ?