Based on this post from here, JQuery multiply input values of table rows, i used the same form field names and added Tax field and Discount field.
<tr class="txtMult">
<td>
<input name="txtEmmail" class="val1" />
</td>
<td>
<input name="txtEmmail" class="val2"/>
</td>
<td>
<span class="multTotal">0.00</span>
</td>
</tr>
<tr class="txtMult">
<td>
<input name="txttax" class="val1" />%
</td>
<td>
</td>
<td>
<span class="multTax">0.00</span>
</td>
</tr>
This tax needs to be multiplied, like if i enter 10 (%)
var $tax = ($val1 * 1) * ($total * 1)/100;
$('.multTax', this).text($tax);
and then out put that as a tax amount I changed the txttax class value as val3 and added the jquery like above
again, I need to subtract the discount, I tried all possible ways, but no luck.
this is the function (Edited)
$(document).ready(function () {
$(".txtMult input").keyup(multInputs);
function multInputs() {
var mult = 0;
$("tr.txtMult").each(function () {
var $val1 = $('.val1', this).val();
var $val2 = $('.val2', this).val();
var $val3 = $('.val3', this).val();
var $total = ($val1 * 1) * ($val2 * 1);
var $tax = ($val1 * 1) * ($total * 1)/100;
$('.multTotal', this).text($total);
$('.multTax', this).text($tax);
mult += $total;
});
$("#grandTotal").text(mult);
}
});
Please advise. (spent the whole day)
$val1,$total, and$taxdefined?.val1, two inputs namedtxtEmmail, and none named.val3, is this intentional? It seems odd and counter to your code.