ASP文本框自动计算代码问题
区区小爱 2015-07-29 03:09:11 <!--#include file="conn.asp"-->
<%
'where seid='"&session("orderid")&"' and pid=pid 为查询二个字段seid与pid,如果这二个字段都相同就显示
set rs=server.createobject("adodb.recordset")
sql="select * from mrcar where seid='"&session("orderid")&"' and pid=pid"
set rs=conn.execute(sql)
price=rs("price")
pcount=rs("pcount")
‘
set rs3=server.createobject("adodb.recordset")
sql="select * from mygtyp where seid='"&session("orderid")&"' and pid=pid"
set rs3=conn.execute(sql)
price3=rs3("price")
pcount3=rs3("pcount")
%>
'自动计算代码
<script>
function cout()
{
var nums=document.getElementById("pcount").value;
var price=document.getElementById("yeshu").value;
if(nums!="" && price!="")
{
var counts=parseInt(nums)*parseInt(price);
document.getElementById("fudongjia").value=counts;
}
}
function cout3()
{
var nums3=document.getElementById("pcount3").value;
var price3=document.getElementById("yeshu3").value;
if(nums3!="" && price3!="")
{
var counts=parseInt(nums3)*parseInt(price3);
document.getElementById("fudongjia3").value=counts;
}
}
function coutzongji()
{
var nums=document.getElementById("pcount").value;
var price=document.getElementById("yeshu").value;
var nums3=document.getElementById("pcount3").value;
var price3=document.getElementById("yeshu3").value;
if(coutzongji!="")
{
var counts=parseInt(nums)*parseInt(price)+parseInt(nums3)*parseInt(price3);
document.getElementById("zongji").value=counts;
}
}
</script>
'A文本框
数量<input name="pcount" type="text" id="pcount" style="text-align:center" onKeyUp="cout();coutzongji();" value="<%=pcount%>" size="8" maxlength="4">
单价<input name="yeshu" type="text" id="yeshu" onKeyUp="cout();coutzongji();" value="<%=price%>" size="8" style="text-align:center">
小计<input name="fudongjia" type="text" id="fudongjia" value="<%=pcount*price%>" size="8" style="text-align:center">
'B文本框
数量B<input name="pcount3" type="text" id="pcount3" style="text-align:center" onKeyUp="cout3();coutzongji();" value="<%=pcount3%>" size="8" maxlength="4">
单价B<input name="yeshu3" type="text" id="yeshu3" onKeyUp="cout3();coutzongji();" value="<%=price3%>" size="8" style="text-align:center">
小计B<input name="fudongjia3" type="text" id="fudongjia3" value="<%=pcount3*price3%>" size="8" style="text-align:center">
A+B的总计<input name="zongji" type="text" id="zongji" value="<%=pcount*price+pcount3*price3%>" size="8" style="text-align:center">
因为我这里面有查询条件,所以A和B都要同时有内容才会得出总计(A或B单独小计变动A+B总计是不会变的),这就是我郁闷的地方,如果能根据A或B的小计变动,A+B的总计也变动就好了,有高手帮我看看吗?