一个用session实现的购物车,请帮忙解决

ad8326 2006-05-27 03:46:30
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<%
id=request.QueryString("id")
ProductList = Session("ProductList")
if Products="" then
Products="noproducts"
end if
Products = Split(ProductList, ", ")

If Len(ProductList) = 0 Then
ProductList = ""&id&""
ElseIf InStr( ProductList, id ) <= 0 Then
ProductList = ProductList & ", " & id & ""
End If


Session("ProductList") = ProductList
response.Write(Session("ProductList"))
set objconn=Server.CreateObject("CustShop.ComClass1")
conn=objconn.DataSource()
set rs=Server.CreateObject("ADODB.Recordset")

%>
<body onload="on_submit()">
<table width="59%" height="30" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="11%"><div align="center">商品名称</div></td>
<td width="10%">商品价格</td>
<td width="13%"><div align="center">商品数量 </div></td>
<td width="12%"><div align="center">小计</div></td>
<td width="54%">修改数量</td>
</tr>
<tr>
<td height="20" colspan="5"><form action="Products_Pay.asp" method="post" name="form1" id="form1">
<table width="63%" border="0" cellspacing="0" cellpadding="0">
<%
For I=0 To UBound(Products)
str="select Products_ID,Products_Name,Products_Price from Cust_Products where Products_ID='"&Products(i)&"'"
rs.open str,conn,1,1
%>
<tr>
<td width="18%" height="30"><div align="center"><a href="Products_View.asp?id=<%=rs("Products_ID")%>" target="_blank"><%=rs("Products_Name")%></a></div></td>
<td width="15%"><div align="center"><%=rs("Products_Price")%></div></td>
<td width="21%"><div align="center">
<input name="number<%=i%>" type="text" value="<%
if request.Form("number"&i)<>"" then
response.Write(request.Form("number"&i))
else
response.Write("1")
end if
%>
"size="7" />
</div></td>
<td width="20%"><div align="center">
<%
if request.Form("number"&i)<>""then
a=cdbl(trim(rs("Products_Price")))
c=cdbl(trim(request.Form("number"&i)))
totalprice=(a*c)
response.Write(totalprice)
else
a=rs("Products_Price")
totalprice=a
response.Write(totalprice)
end if
%>
</div></td>
<td width="26%"><input type="submit" name="Submit" value="修改" /></td>
</tr>
<%
totalall=totalall+totalprice
session("totalall")=totalall
rs.movenext
rs.close
pnumber=request.Form("number"&i)
if i=0 then
ProductNum = pnumber
else
ProductNum = ProductNum & "," &pnumber&""
end if
next
session("ProductNum")=ProductNum
response.Write(session("ProductNum"))
par=request.QueryString("par")
if par=1 then
session("ProductList")=""
end if
%>
</table>
</form></td>
</tr>
</table>
<table width="22%" height="29" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="29">总价格为:<%=totalall%></td>
</tr>
</table>
<table width="54%" height="26" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="34%"><div align="center"><a href="Products_Buy.asp?i=<%=i%>" onclick="javascript:eval('document.form1.submit()');">下一步</a></div></td>
<td width="28%"><div align="center"><a href="index.asp">继续购物</a><a href="Products_Buy.asp?i=<%=i%>" onmouseup="onload()"></a></div></td>
<td width="38%"><div align="center"><a href="Products_Pay.asp?par=1">清空购物车</a></div></td>
</tr>
</table>
</body>
</html>

我遇到的问题是 必须要刷新一次才能显示出来购买的商品,
而且还要提交一次表单 session("ProductNum")才有数据,请问如何解决
...全文
213 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ad8326 2006-05-27
  • 打赏
  • 举报
回复
点击一个商品后进到这个页面没有任何的数据,用打印测试发现
For I=0 To UBound(Products)
str="select Products_ID,Products_Name,Products_Price from Cust_Products where Products_ID='"&Products(i)&"'"
没有执行
以后每添加一个商品 都少一个数据 只有提交一次表单数据才能正确 这是什么问题
ad8326 2006-05-27
  • 打赏
  • 举报
回复
能不能不刷新就出来啊
ad8326 2006-05-27
  • 打赏
  • 举报
回复
加了 不是这个问题啊
moodboy1982 2006-05-27
  • 打赏
  • 举报
回复
交易后自动刷新一次。
jinfeng003 2006-05-27
  • 打赏
  • 举报
回复
开头加上
<%response.Expires=-1%>让当前页面不缓存

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧