TextBox:(多个TextBox求和问题)
来源:互联网 发布:淘宝市场行情专业版 编辑:程序博客网 时间:2024/05/15 06:21
偶然看到一张出差申请单,闲着没事,就做了其中的一部分,算是练习吧!嘿嘿。。。
<script type="text/javascript" language="javascript">
//禁止输入非数字
function JHshNumberText() {
if (!(((window.event.keyCode >= 48) && (window.event.keyCode <= 57))
|| (window.event.keyCode == 13) || (window.event.keyCode == 46)
|| (window.event.keyCode == 45))) {
window.event.keyCode = 0;
}
}
//小计
function getSum(_obj) {
var tr = _obj.parentNode.parentNode;
var price = tr.cells[1].firstChild; //单价
var Peosernumber = tr.cells[2].firstChild;//人次
var tb_daycounts = tr.cells[3].firstChild; //天数
tr.cells[4].firstChild.value = (price.value == "" ? 0 : price.value) * (Peosernumber.value == "" ? 0 : Peosernumber.value) * (tb_daycounts.value == "" ? 0 : tb_daycounts.value);
}
//合计
function getAllSum() {
var sum1 = document.getElementById("tb_count");
var sum2 = document.getElementById("tb_count0");
var sum3 = document.getElementById("tb_count1");
var sum4 = document.getElementById("tb_count2");
document.getElementById("tb_totalCount").value =
(sum1.value == "" ? 0 : parseInt(sum1.value)) + (sum2.value == "" ? 0 : parseInt(sum2.value)) + (sum3.value == "" ? 0 : parseInt(sum3.value)) + (sum4.value == "" ? 0 : parseInt(sum4.value));
}
</script>
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="style7">项目</td>
<td>单价</td>
<td>人次</td>
<td class="style3">天数</td>
<td>小计</td>
<td>说明</td>
</tr>
<tr>
<td class="style7">住宿</td>
<td>
<asp:TextBox ID="tb_cost" runat="server" Width="80px" tip="设置单价" onKeyPress="JHshNumberText()" onblur="getSum(this)">
</asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_Peosernumber" runat="server" Width="80px" tip="设置人次" onKeyPress="JHshNumberText()" onblur="getSum(this)">
</asp:TextBox>
</td>
<td class="style3">
<asp:TextBox ID="tb_daycounts" runat="server" Width="80px" tip="设置天数" onKeyPress="JHshNumberText()" onblur="getSum(this)">
</asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_count" runat="server" Width="80px" onKeyPress="JHshNumberText()" onblur="getSum(this)">
</asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_remark" runat="server" Width="110px" tip="备注或说明"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style8">交通</td>
<td class="style9">
<asp:TextBox ID="tb_cost0" runat="server" Width="80px" onKeyPress="JHshNumberText()" onblur="getSum(this)"></asp:TextBox>
</td>
<td class="style9">
<asp:TextBox ID="tb_Peosernumber0" runat="server" Width="80px" onKeyPress="JHshNumberText()" onblur="getSum(this)"></asp:TextBox>
</td>
<td class="style10">
<asp:TextBox ID="tb_daycounts0" runat="server" Width="80px" onKeyPress="JHshNumberText()" onblur="getSum(this)"></asp:TextBox>
</td>
<td class="style9">
<asp:TextBox ID="tb_count0" runat="server" Width="80px"></asp:TextBox>
</td>
<td class="style9">
<asp:TextBox ID="tb_remark0" runat="server" Width="110px" onKeyPress="JHshNumberText()" onblur="getSum(this)"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style7">交际</td>
<td>
<asp:TextBox ID="tb_cost1" runat="server" Width="80px" onKeyPress="JHshNumberText()" onblur="getSum(this)"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_Peosernumber1" runat="server" Width="80px" onKeyPress="JHshNumberText()" onblur="getSum(this)"></asp:TextBox>
</td>
<td class="style3">
<asp:TextBox ID="tb_daycounts1" runat="server" Width="80px" onKeyPress="JHshNumberText()" onblur="getSum(this)"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_count1" runat="server" Width="80px" onKeyPress="JHshNumberText()" onblur="getSum(this)"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_remark1" runat="server" Width="110px" onKeyPress="JHshNumberText()" onblur="getSum(this)"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style7">其他</td>
<td>
<asp:TextBox ID="tb_cost3" runat="server" Width="80px" onKeyPress="JHshNumberText()" onblur="getSum(this)"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_cost4" runat="server" Width="80px" onKeyPress="JHshNumberText()" onblur="getSum(this)"></asp:TextBox>
</td>
<td class="style3">
<asp:TextBox ID="tb_daycounts2" runat="server" Width="80px" onKeyPress="JHshNumberText()" onblur="getSum(this)"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_count2" runat="server" Width="80px" onKeyPress="JHshNumberText()" onblur="getSum(this)"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_remark2" runat="server" Width="110px" onKeyPress="JHshNumberText()" onblur="getSum(this)"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style7">合计</td>
<td colspan="5" align="left">
<asp:TextBox ID="tb_totalCount" runat="server" Width="170px"
onKeyPress="JHshNumberText()" onfocus="getAllSum()"></asp:TextBox>
</td>
</tr>
</table>
- TextBox:(多个TextBox求和问题)
- TextBox
- textbox
- textbox
- TextBox
- TextBox
- textbox
- TextBox
- textbox 获得焦点问题
- TextBox的Enabled问题
- DataList中的TextBox问题
- textbox 自动换行问题
- textBox换行问题
- TextBox缓存问题
- ZK提交textbox内奇数个中文汉字乱码问题
- 关于多个textbox的leave,changed事件
- 使用回车键在多个textbox中跳转
- 判断多个textbox中是否有为空
- select、Poll、epoll比较。
- CEventListComparer
- WiMAX
- 最值钱的JavaScript函数:$
- 字符串的排列--总结
- TextBox:(多个TextBox求和问题)
- 连接ACCESS数据库
- WiMax到底是 3G
- C# Socket多线程编程实例
- 求助 求助 BIRT CHART 汉字问题
- AS3常用代码整理及细节优化注意
- Could not find main class javacc
- Java版结果集行列倒置
- Mysql 缓存参数.