I'm currently writing a small plugin for computer repair techs and I'm now trying to code the invoice section but not having much luck!
I've got the fields being populated from the database but I'm trying to use jquery to update the line totals and the total of the invoice.
Heres a quick image of what I'm trying to do!
I'm trying to get it to update the totals on pageload and when a value changes in the unit cost and quantity textfields.
$(document).ready(function() {
$("#invoiceitems tbody tr").each(function() {
$(this).change(function() {
updateTotal();
});
});
});
function updateTotal() {
//Calculate Subtotal for each item
var quantity = $('.quantity').val();
var price = $('.price').val();
var subtotal = parseInt(quantity) * parseFloat(price);
$('.subtotal').text(subtotal);
//Calculate Grand Total
var sum = 0;
$('.linetotal').each(function() {
sum += parseFloat($(this).text());
});
$('#grandTotal').html(parseFloat(sum));
}
Found this code on here but I really don't have a clue and can't get it to work!
Some direction/help would be greatly appreciated!
Thanks very much Jase