Hello:
I need some assistance with a jquery/javascript code. I have a form with chain-linked list box of product, and prices. Each product is inside a <tr> which are added as needed. So there can be many items added to the form. The total of the items cost (qty*cost) from all added <tr> goes inside an input box called subtotal. Once I have the total, another checkbox if check adds a percentage of tax based on that subtotal.
the code to calculate my subtotal of all added <tr> is:
function update() {
var subtotal = 0;
var errorMsg = "N/A";
$('.price' , $item_rows_container).each(function(i) {
var row = $(this).closest('tr');
var price = row.find('.costbox').val().fromCurrency() * Number(row.find('.qtybox').val());
$(this).html(isNaN(price) ? errorMsg : price.toCurrency());//Display value or 'error' if calculation failed
subtotal += price.toCurrency().fromCurrency();
});
$('#subtotal').html(isNaN(subtotal) ? errorMsg : subtotal.toCurrency());
code to calculate the tax on the subtotal:
var tax = ($('#taxbox').attr('checked')) ? (subtotal * taxRate) : 0;
$('#tax').val(isNaN(tax) ? errorMsg : tax.toCurrency());
Now inside each <tr>, i have a <td> with a checkbox which when checked, I would like to exclude the total of this <tr> from the form's subtotal. I would then want a separate inputbox with the total of all items that have been check as tax exempted.
To finalize the form's transaction, I would have a box of a sutotal of taxable items, a box for the total of non-taxable items, a box of the tax amount and then add all three for my grand total.
Can anyone help me on this, I'm appreciative of any assistance.
Best,
Mossa