你能帮我解释一下为什么我的工作工资计算功能在这段代码中不起作用吗?(在我添加“Do while”循环之前它工作得很好。)
我想要的是首先从数据库中检索工资金额,然后该用户可以输入其他费用并对每个生成的记录进行报酬。当用户得到满意的结果时,他可以将其保存回数据库。
谢谢,
我的代码如下:
<%
Do while Not Rs.EOF
if rs.fields.item("if_social_sec") = "True" then
displaytxt = ""
soc_sec_v = soc_sec
else
displaytxt = "none"
soc_sec_v = 0
end if
%>
<table>
<form name="myform2" action="salary_action.asp" method="POST">
<tr bgcolor="#<%=color%>">
<td class="btline" width="25" align="center"><input type="checkbox" name="lb_id" value="<%=lb_id%>" onClick="highlightRow(this,'#FFFFCC','#EFF4FA');"></td>
<td class="btline difcursor" nowrap width="7%"> <%=rs.fields.item("lb_name")%></td>
<td class="btline" nowrap width="10%"><input type="text" name="working_day" id="working_day" value="<%=rs.fields.item("MaxOfdays")%>" size="7" onFocus="startCalc();" onBlur="stopCalc();"></td>
<td class="btline " nowrap width="10%"><input type="text" name="wage" id="wage" value="<%=formatnumber(rs.fields.item("Total"),2)%>" onFocus="startCalc();" onBlur="stopCalc();"></td>
<td class="btline " nowrap width="8%"><input type="text" name="OT" id="OT" size="7" onFocus="startCalc();" onBlur="stopCalc();"><input type="hidden" id="OT_rate" value="<%=rs.fields.item("lbOT")%>" ></td>
<td class="btline " nowrap width="8%" ><input type="text" name="soc_sec" id="soc_sec" size="7" value="<%=soc_sec_v%>" onFocus="startCalc();" onBlur="stopCalc();"></td>
<td class="btline" nowrap style="padding-left: 10px" width="8%" ><input type="text" name="ex_pay" id="ex_pay" size="7" onFocus="startCalc();" onBlur="stopCalc();"></td>
<td class="btline bold" width="10%"><input type="text" name="net_wage" id="net_wage" size="7" disabled></td>
<td class="btline" ><input type="submit"></td>
</tr>
</form>
<%
Rs.movenext
n = n + 1
Loop
End if
Rs.close
set Rs=nothing
Call DBConnClose()
%>
</table>
<script>
function startCalc(){
interval = setInterval("calc()",1);
}
function calc(){
wage = document.myform2.wage.value;
OT_rate = document.myform2.OT_rate.value;
OT = document.myform2.OT.value;
OT_amt = OT_rate * OT;
soc_sec = document.myform2.soc_sec.value;
ex_pay= document.myform2.ex_pay.value;
net_wage = (wage * 1) + (OT_amt * 1) - (soc_sec * 1) + (ex_pay * 1);
document.myform2.net_wage.value = net_wage.toFixed(2);
}
function stopCalc(){
clearInterval(interval);
}
</script>