I have code which calculates 8% of the number entered, so for example is in the code below. If you enter "1" in the first box" and "100" in the second box the Total Refund (including 8%) = 108
JavaScript code:
Code:$(document).ready(function() { var sum = 0; function calcSum(prevVal) { var val1 = $('#val1').val(); var val2 = $('#val2').val(); var val3 = $('#val3').val(); var val4 = $('#val4').val(); this.sum = parseFloat(val1) * parseFloat(val2) + parseFloat(val3) * parseFloat(val4); return this.sum; } var subAmt = $("#sub"), taxAmt = $("#tax"), totAmt = $("#total"); $(".val").each(function() { var prevVal = this.value / 1, self = this; $(this).keyup(function() { subAmt.val(calcSum.call(self, prevVal)); totAmt.val(this.sum + this.sum * parseFloat(taxAmt.val() / 100)); prevVal = self.value; }); }); });
http://jsfiddle.net/2k1zr59u/3/
What I would like to do is to calculate 20% of the 8% in the second to the bottom box. So in this example the answer should be 1.60.
Then I would like to show in the total box 106.40 (108 - 1.60).



Reply With Quote

Bookmarks