Calculate sum of checkbox values (Grid) in Master Details

I have a master detail from for creating an invoice.
A tax has to be applied to the item cost before doing the line total.
I have have a TAX FLAG field (a checkbox), with a value(PERCENTAGE) from a lookup table.
On checking a box, a formula multiplies it by the item price to get the tax amount then inserts it into the TAX AMOUNT FIELD.Problem: There are 2 types of taxes that can be applied to the item price and they are cumulative i.e
TOTAL_TAX_PERCENTAGE= PERCENTAGE_A + PERCENTAGE_B,
after which:
TAX AMOUNT = TOTAL_TAX_PERCENTAGE * ITEM_PRICEMy current code does not add up PERCENTAGE_A and PERCENTAGE_B but rather replaces PERCENTAGE_A with PERCENTAGE_B hence tax is not accumulated.A snippet of my code below, at field setup-client side events.{ // keys = event types, values = handler functions
“click”: function(e) {
var $row = $(this).fields();
var tot_tax = 0;
$(this).each(function(){
if($(this).is(‘:checked’)){
tot_tax=tot_tax+parseInt($(this).val());
//var tax_amount = ($row[“ps_rate”].toNumber()(tot_tax/100));
//$row[“ps_tax_amt”].value(tax_amount.toFixed(2));
}else{
$row[“ps_tax_amt”].value(‘’);
}
var tax_amount = ($row[“ps_rate”].toNumber()(tot_tax/100));
$row[“ps_tax_amt”].value(tax_amount.toFixed(2));
});
}
}

My current code does not add up PERCENTAGE_A and PERCENTAGE_B but rather replaces PERCENTAGE_A with PERCENTAGE_B hence tax is not accumulated.Cannot see anywhere in your codes where you process the percentages. Please elaborate and explain more in details.

Sorry, at this point: tot_tax/100The value comes as a whole number and is converted to a decimal for multiplication with the item price.

Make sure that the value is not treated as integer. Use:
tot_tax * 1.0 / 100