ASP文本框自动计算代码问题
<!--#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的总计也变动就好了,有高手帮我看看吗?
<%
'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的总计也变动就好了,有高手帮我看看吗?
...全文
相关推荐
用ASP实现一个计算题
自己觉得不错,可以看看 需以下三个文件: Calculate.aspx bin/Calculate.cs bin/Calculate.bat
asp maker8.0自动生成asp网站的软件最新版
asp maker8.0自动生成asp网站的软件最新版,不错的软件分享给大家.
asp.net页面代码实现
是一个不错的抽油机系数的模块代码,里面的代码已经经过测试
毕业答辩-ASP在线考试系统毕业设计(源代码论文).rar
ASP在线考试系统毕业设计(源代码论文).rar
ASP.NET办公自动化系统开发实例导航 随书光盘
ASP.NET办公自动化系统开发实例导航 随书光盘


