项目 | 单价 | 人次 | 天数 | 小计 | 说明 |
住宿 | |||||
交通 | |||||
交际 | |||||
其他 | |||||
合计 |
偶然看到一张出差申请单,闲着没事,就做了其中的一部分,算是练习吧!嘿嘿。。。
<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()" οnblur="getSum(this)">
</asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_Peosernumber" runat="server" Width="80px" tip="设置人次" onKeyPress="JHshNumberText()" οnblur="getSum(this)">
</asp:TextBox>
</td>
<td class="style3">
<asp:TextBox ID="tb_daycounts" runat="server" Width="80px" tip="设置天数" onKeyPress="JHshNumberText()" οnblur="getSum(this)">
</asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_count" runat="server" Width="80px" onKeyPress="JHshNumberText()" οnblur="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()" οnblur="getSum(this)"></asp:TextBox>
</td>
<td class="style9">
<asp:TextBox ID="tb_Peosernumber0" runat="server" Width="80px" onKeyPress="JHshNumberText()" οnblur="getSum(this)"></asp:TextBox>
</td>
<td class="style10">
<asp:TextBox ID="tb_daycounts0" runat="server" Width="80px" onKeyPress="JHshNumberText()" οnblur="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()" οnblur="getSum(this)"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style7">交际</td>
<td>
<asp:TextBox ID="tb_cost1" runat="server" Width="80px" onKeyPress="JHshNumberText()" οnblur="getSum(this)"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_Peosernumber1" runat="server" Width="80px" onKeyPress="JHshNumberText()" οnblur="getSum(this)"></asp:TextBox>
</td>
<td class="style3">
<asp:TextBox ID="tb_daycounts1" runat="server" Width="80px" onKeyPress="JHshNumberText()" οnblur="getSum(this)"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_count1" runat="server" Width="80px" onKeyPress="JHshNumberText()" οnblur="getSum(this)"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_remark1" runat="server" Width="110px" onKeyPress="JHshNumberText()" οnblur="getSum(this)"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style7">其他</td>
<td>
<asp:TextBox ID="tb_cost3" runat="server" Width="80px" onKeyPress="JHshNumberText()" οnblur="getSum(this)"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_cost4" runat="server" Width="80px" onKeyPress="JHshNumberText()" οnblur="getSum(this)"></asp:TextBox>
</td>
<td class="style3">
<asp:TextBox ID="tb_daycounts2" runat="server" Width="80px" onKeyPress="JHshNumberText()" οnblur="getSum(this)"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_count2" runat="server" Width="80px" onKeyPress="JHshNumberText()" οnblur="getSum(this)"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="tb_remark2" runat="server" Width="110px" onKeyPress="JHshNumberText()" οnblur="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()" οnfοcus="getAllSum()"></asp:TextBox>
</td>
</tr>
</table>