I am using Asp.net to build a loan calculator where through CNIC search it will calculate all fields as well as fetch other details from database.
Now i have a situation where i am stuck,
I have a table in the database which tells how much tax will be deducted based on income. I am fetching the Income automatically on the frontend on cnic search using JavaScript. Now i want to do two things. 1. When the Income is searched i want to automatically calculate the tax aswell based on that database table and display at frontend. 2. Lets say wrong income was fetched using the cnic search, now when the user updates income on frontend a onkeyup event should get fired and the tax should be calculated on the runtime.
Below is my JavaScript Code, here tax_income is used to calculate the tax based on the database table.
var start=0;
var v_tfx=0;
var rate=0;
function SearchRefNo(btn) {
btn = $(btn);
var input = btn.prev();
Proxy('CI_InputRefNo&REF_NO=' + input.val(), { Inf: '' }, function (ds) {
var res=ds[0];
start=ds[1][0]['START'];
v_tfx=ds[1][0]['FIXED_TAX'];
rate=ds[1][0]['RATE'];
tax_income =(((res[0].GINCOME * 12) - start) * rate + v_tfx / 12);
var group = btn.parents('[group-no]:first');
if (res != null) {
$('.customer-name').val(res[0].CUSTOMER_NAME);
$('.cnic').val(res[0].CNIC_NUMBER);
$('.dob').val(res[0].DOB);
$('.g-income').val(res[0].GINCOME);
$('.deduction').val(res[0].DEDUCTION);
$('.net-income').val(res[0].NET_INCOME);
$('.t-income').val(res[0].T_INCOME);
}
});}
And since, i want to calculate the tax if user manually inputs in the gross income field therefore i have used repeater below to fetch the Income Tax Rate table through a repeater.
<script type="text/javascript">
var markers = [];
<asp:Repeater ID="rptMarkers" runat="server">
<ItemTemplate>
markers.push({"Start": '<%# Eval("START") %>',"Fixed_Tax": '<%# Eval("FIXED_TAX") %>',"Rate": '<%# Eval("RATE") %>',"W_E_F": '<%# Eval("W_E_F") %>'});
</ItemTemplate>
</asp:Repeater>
</script>
What I have tried:
Tried the code that i have pasted