选择的信息自动求和且显示
老师:我想每选择一条信息,选中的数量就会自动相加,并且同步显示出来,我是像下面这样做的,但是不行,怎么改?谢谢!
<%
if request.form("Submit")="开票" then
fapiao=Trim(request.form("fapiao"))
id=request.form("id")
if id<>"" and not isnull(id) then
conn.execute "update xiaoshou set fapiao='"&fapiao&"' where id in ("&id&")"
response.redirect Request.ServerVariables("fapiao.asp")
end if
end if
%>
<table
<tr>
<td>选择</td>
<td>数量</td>
</tr>
<form method="post">
<%
Gname=request.form("Gname")
Set rs=server.createobject("adodb.recordset")
rs.open "select id,shuliang from xiaoshou where Gname='"&Gname&"' order by id desc",conn,1,1
Set id=rs("id")
Set shuliang=rs("shuliang")
do while not rs.eof
%>
<tr >
<td><input name="id" type="checkbox" id="id" value="<%=cstr(rs("id"))%>"></td>
<td><%=shuliang%></td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<tr >
<td><%
set rs=server.CreateObject("adodb.recordset")
sql="select sum(shuliang) as shuliang1 FROM xiaoshou WHERE ID=" & CLng(ID)
rs.open sql,conn,1,1
%>
数量【<%=rs("shuliang1")%>】个
<%
rs.close
set rs=nothing
%>
<td ><input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
全选</td>
<td><input type="text" name="fapiao" /> <input type="Submit" name="Submit" value="开票" /></td>
</tr>
</form>
<SCRIPT language=javascript>
//全选功能
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.Name != "chkAll")
e.checked = form.chkAll.checked;
}
}
</SCRIPT>
</table>