| 項目 |
單價 |
人次 |
天數 |
小計 |
說明 |
| 住宿 |
|
|
|
|
|
| 交通 |
|
|
|
|
|
| 交際 |
|
|
|
|
|
| 其他 |
|
|
|
|
|
| 合計 |
|
偶然看到一張出差申請單,閑著沒事,就做了其中的一部分,算是練習吧!嘿嘿。。。
<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>