注册 登录
编程论坛 ASP.NET技术论坛

asp.net加法计算 如果使用js 请给出详细代码

mouseten 发布于 2013-02-18 17:18, 590 次点击
程序代码:
<table style="text-align:center; width:300px;">
            <tr>
                <td>
                <input id="tb_numberA" type="text" value="0"/>
                    </td>
                <td class="auto-style2">+</td>
                <td class="auto-style2">
                    <input id="tb_numberB" type="text" value="0"/>
                </td>
                <td class="auto-style2">
                    <input id="Button1" type="button" value="=" onkeyup="sum()"/>
                </td>
                <td class="auto-style2">
                    <input id="result" type="text" />
                </td>
            </tr>
        </table>
2 回复
#2
mouseten2013-02-19 09:13
一个加法功能啊
#3
冰蟾子2013-02-25 01:15
程序代码:

<input id="Button1" type="button" value="=" onkeyup="sum()"/>//改为<input id="Button1" type="button" value="=" onclick="sum()"/>

<script type="text/javascript">
    function sum(){
        function $(str){
            return document.getElementById(str);
        }
        $("result").value=parseFloat($("tb_numberA").value)+parseFloat($("tb_numberB").value);
    }
</script>
1