| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦   
共有 197 人关注过本帖
标题:选择的信息自动求和且显示
收藏  订阅  推荐  打印
anjincheng
Rank: 3Rank: 3
等级:中级会员
帖子:459
积分:4778
注册:2005-7-27
选择的信息自动求和且显示

老师:
    我想每选择一条信息,选中的数量就会自动相加,并且同步显示出来,我是像下面这样做的,但是不行,怎么改?谢谢!
<%
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>
2008-6-14 22:06
21411
Rank: 1
等级:新手上路
帖子:23
积分:408
注册:2008-1-10

conn.execute "update xiaoshou set fapiao='"&fapiao&"' where id in ("&id&")"
改为
conn.execute "update xiaoshou set fapiao='"&fapiao&"' where id = "&id&""
2008-6-15 12:11
共有 196 人关注过本帖
发新话题
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.049939 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved