如何使用javascript计算税额和税率? [英] how to calcutate tax amount and tax rate using javascript ?

查看:137
本文介绍了如何使用javascript计算税额和税率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本框,分别为1)税额和2)税率
如果我在税额"文本框1中输入税额,我想计算税额百分比
如果我在第二个文本框中输入税率,则应使用javascript
计算税额
谁能帮我在javascript

i have two textboxes called 1) tax amount and 2)tax percentage
if i enter amount in tax amount textbox1 i want to calculate tax percentage
if i enter tax percentage in second text box it should calcuate tax amount using javascript

can any one help me how to do this in javascript

推荐答案

尝试此方法
设计
Try this
Design
<asp:TextBox ID="txt1"  runat="server"></asp:TextBox>

<asp:TextBox ID="txt2" onkeypress="taxCalc();" runat="server"></asp:TextBox>

<asp:TextBox ID="txt3" runat="server"></asp:TextBox>



javascript



javascript

<script language="javascript" type="text/javascript">
function taxCalc()
    {
        var _txt1 = document.getElementById('<%= txt1.ClientID %>');
        var _txt2 = document.getElementById('<%= txt2.ClientID %>');
        var _txt3 = document.getElementById('<%= txt3.ClientID %>');
        var t1=0, t2=0;

        if(_txt1.value != "") t1=_txt1.value;
        if(_txt2.value != "") t2=_txt2.value;

        _txt3.value = parseInt(t1) * parseInt(t2)/100;
    }
    </script>


这篇关于如何使用javascript计算税额和税率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆