我有一个工资计算表格,它从从数据库中检索工资总和开始,然后在用户添加一些额外的付款以计算净工资后,再次将它们保存回数据库。
我的问题是我的代码一次只能保存一条记录。我需要的是能够同时保存所有记录。所以你能帮帮我吗?
<%
if Rs.eof then
response.write "<tr><td colspan=""9""> "
call displayNotFoundRecord
response.write "</td></tr>"
Else
Do while Rs.AbsolutePage = strPageCurrent And Not Rs.EOF
dim color
y = n mod 2
if y > 0 then
color = "EFF4FA"
else
color = "ffffff"
end if
if rs.fields.item("if_social_sec") = "True" then
displaytxt = ""
soc_sec_v = soc_sec
else
displaytxt = "none"
soc_sec_v = 0
end if
wage_v = rs.fields.item("Total")
salary_v = rs.fields.item("lb_salary")
if rs.fields.item("lb_type") = "perunit" then
salary_wage = wage_v
displaytxt_w = "readonly class=""bgdisable"""
displaytxt_lb = "readonly class=""bgdisable"""
else
salary_wage = salary_v
displaytxt_w = ""
displaytxt_lb = ""
end if
if_pm = request.form("if_pm")
pm_pay = rs.fields.item("lb_pmPay")
if if_pm <> "" then
if_pm_v = pm_pay
disable_txt_pm = "readonly"
else
if_pm_v = 0
disable_txt_pm = "readonly class=""bgdisable"""
end if
%>
<form name="myform2_<%=n%>" action="salary_action.asp" method="POST">
<tr bgcolor="#<%=color%>">
<td class="btline difcursor" nowrap width="7%"> <%=rs.fields.item("lb_name")%></td>
<td class="btline center" nowrap width="8%"><input type="text" name="working_day" id="working_day" value="<%=rs.fields.item("MaxOfdays")%>" size="7" <%=displaytxt_w%> onFocus="startCalc(this);" onBlur="stopCalc(this);"></td>
<td class="btline " nowrap width="10%"><input type="text" name="wage" id="wage" value="<%=salary_wage%>" onFocus="startCalc(this);" onBlur="stopCalc(this);"></td>
<td class="btline center" nowrap width="8%"><input type="text" name="OT" id="OT" size="7" value="<%=if_OT_v%>" onFocus="startCalc(this);" onBlur="stopCalc(this);" <%=disabled_ot%>></td>
<td class="btline center" nowrap width="6%" ><input type="text" name="OT_rate" id="OT_rate" size="5" value="<%=rs.fields.item("lbOT")%>" <%'=disabled_txt%> readonly class="bgdisable"></td>
<td class="btline center" nowrap width="6%" ><input type="text" name="OT_amt" id="OT_amt" size="5" value="" <%'=disabled_txt%> readonly class="bgdisable"></td>
<td class="btline center" nowrap width="8%" ><input type="text" name="soc_sec" id="soc_sec" size="7" value="<%=soc_sec_v%>" <%=disable_txt_soc%> onFocus="startCalc(this);" onBlur="stopCalc(this);"></td>
<td class="btline center" nowrap width="8%"><input type="text" name="pmPay" id="pmPay" size="7" value="<%=if_pm_v%>" onFocus="startCalc(this);" onBlur="stopCalc(this);" <%'=disable_txt_pm%> readonly class="bgdisable"></td>
<td class="btline" nowrap style="padding-left: 10px" width="8%" ><input type="text" name="ex_pay" id="ex_pay" size="7" onFocus="startCalc(this);" onBlur="stopCalc(this);"></td>
<td class="btline bold " width="10%"><input type="text" name="net_wage" id="net_wage" size="7" readonly class="bgdisable">
<input type="hidden" name="lb_type" id="lb_type" size="7" value="<%=rs.fields.item("lb_type")%>">
<input type="hidden" name="date_from" id="date_from" size="7" value="<%=date_from_txt%>">
<input type="hidden" name="date_to" id="date_to" size="7" value="<%=date_to_txt%>">
<input type="hidden" name="lb_id" id="lb_id" size="7" value="<%=rs.fields.item("lb_id")%>">
<input type="hidden" value="N" name="edit_salary">
</td>
<td class="btline"><input type="text" name="sar_note" value="" size="14"></td>
<td class="btline" > <input type="submit" value="Save1"></td>
</tr>
</form>
<%
Rs.movenext
n = n + 1
Loop
End if
Rs.close
set Rs=nothing
Call DBConnClose()
%>
<tr>
<td colspan="12" align="center" style="padding:10px;">
<input type="submit" value="Save2">
</td>
</tr>
我需要的是让“Save2”工作。但现在只有“Save1”有效。
添加(我的脚本):
<script>
var intervals = {};
function startCalc(sender){
var key = sender.form.name;
intervals[key] = setInterval(function() {
calc(key);
},1);
}
function calc(key){
var oForm = document.forms[key];
working_day = oForm.working_day.value;
wage = oForm.wage.value;
lb_type_v = oForm.lb_type.value;
if (lb_type_v == "daily")
{
wage = wage * working_day;
}
else
{
wage = wage;
}
OT_rate = oForm.OT_rate.value;
OT = oForm.OT.value;
OT_amt = OT_rate * OT;
soc_sec = oForm.soc_sec.value;
ex_pay= oForm.ex_pay.value;
pmPay = oForm.pmPay.value;
net_wage = (wage * 1) + (OT_amt * 1) - (soc_sec * 1) + (ex_pay * 1) + (pmPay * 1);
oForm.OT_amt.value = OT_amt;
oForm.net_wage.value = net_wage.toFixed(2);
}
function stopCalc(sender){
var key = sender.form.name;
clearInterval(intervals[key]);
}
</script>