问题描述
我正在使用Asp.net建立一个贷款计算器,通过CNIC搜索它将计算所有字段以及从数据库中获取其他详细信息。
现在我有一种情况我被困住了,
我在数据库中有一张表,说明将根据收入扣除多少税款。我正在使用JavaScript在cnic搜索的前端自动获取收入。现在我想做两件事。 1.当搜索收入时,我想根据该数据库表自动计算税额并在前端显示。 2.假设使用cnic搜索获取了错误的收入,现在当用户在前端更新收入时,onkeyup事件应该被解雇,税收应该在运行时计算。
下面是我的JavaScript代码,这里tax_income用于根据数据库表计算税额。
var start = 0;
var v_tfx = 0;
var rate = 0;
函数SearchRefNo(btn){
btn = $(btn);
var input = btn.prev();
代理('CI_InputRefNo& REF_NO ='+ input.val(),{Inf:''},函数(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);
}
});}
因为,如果用户手动输入总收入字段,我想计算税,因此我使用了转发器下面通过代表获取所得税率表食客。
< script type =text / javascript>
var markers = [];
< asp:Repeater ID =rptMarkersrunat =server>
< ItemTemplate>
markers.push({开始:'<%#Eval(START)%>',Fixed_Tax:'<%#Eval(FIXED_TAX)%>',评价:'<%#Eval(RATE)%>',W_E_F:'<%#Eval(W_E_F)%>'});
< / ItemTemplate>
< / asp:Repeater>
< / script>
我尝试过:
尝试了我粘贴的代码
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
这篇关于使用javascript基于用户输入和数据库表进行实时计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!