因为对asp不是很在行
想请教两个关于购物车的问题
1、如何保存下拉框的值,想写入session,原有的session只保存商品的ID,不知道怎么改。
2、如何点删除字样删除一个商品。
最主要的第一个问题,不尽感激~~(-_-)
源代码如下
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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>kylin-trade</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<!--#include file="include/conn.asp" -->
<!--#include file="include/include.asp" -->
<!--#include file="chk_user.asp" -->
</head>
<body>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="80"> </td>
</tr>
<tr>
<td>
<%
if request("ProductList")="ProductList" then
Session("ProductList")=""
response.Write("<script>alert('Your Inquiry Basket is Empty!');window.location.href='index.asp';</script>")
end if
ProductList = Session("ProductList")
Products = Split(Request("Prodid"), ",")
For I=0 To UBound(Products)
PutToShopBag Products(I), ProductList
Next
Session("ProductList") = ProductList
Sub PutToShopBag( Prodid, ProductList )
If Len(ProductList) = 0 Then
ProductList =Prodid
ElseIf InStr( ProductList, Prodid ) <= 0 Then
ProductList = ProductList&", "&Prodid &""
End If
End Sub
If Request("update") = "update" Then
ProductList = ""
Products = Split(Request("ProdId"), ", ")
For I=0 To UBound(Products)
PutToShopBag Products(I), ProductList
Next
Session("ProductList") = ProductList
End If
If Len(Session("ProductList")) = 0 Then
response.Write("<script>alert('Your Inquiry Basket is Empty!');window.location.href='index.asp';</script>")
Response.end
end if
%>
<form action="gouwu.asp" method="POST" name="check">
<table width="760" border="0" cellpadding="0" cellspacing="1" bgcolor="#C7D9C0">
<%
Set rs=Server.CreateObject("ADODB.RecordSet")
strsql="select * from shangpin where ID in ("&Session("ProductList")&") order by ID"
rs.open strsql,conn,1,1
%>
<tr>
<td height="30" colspan="5" align="center" bgcolor="#EAF5E6">Goods information chosen</td>
</tr>
<tr>
<td width="80" height="30" align="center" bgcolor="#FAFDF9">Number</td>
<td width="206" align="center" bgcolor="#FAFDF9">Product Name</td>
<td width="188" align="center" bgcolor="#FAFDF9">Picture</td>
<td width="140" align="center" bgcolor="#FAFDF9">Size</td>
<td width="140" align="center" bgcolor="#FAFDF9">Quantity</td>
</tr>
<%
Quantity = 1
Do While Not rs.EOF
Quantity = Request.Form( "Q_" & rs("ID"))
If Quantity <= 0 Then
Quantity = Session(rs("ID"))
If Quantity <= 0 Then Quantity = 1
End If
Session(rs("ID")) = Quantity
%>
<tr>
<td height="70" align="center" bgcolor="#FFFFFF"><input type="checkbox" name="ProdId" value="<%=rs("ID")%>" Checked
/></td>
<input type="hidden" name="shuliang" value="<%=Quantity%>">
<td height="70" align="center" bgcolor="#FFFFFF"><a href="lookpro.asp?ID=<%=rs("ID")%>" target="_blank"
class="blue"><%=rs("mingchen")%></a></td>
<td align="center" bgcolor="#FFFFFF"><a href="lookpro.asp?id=<%=rs("id")%>" target="_blank"><img src="upfile/<%=rs
("tupian")%>" width="75" height="56" border="0" alt="<%=rs("mingchen")%>" /></a></td>
<td align="center" bgcolor="#FFFFFF">
<select name="chicun">
<%
set rs2=Server.CreateObject("ADODB.Recordset")
sql2="select chicun from shangpin where ID in (" & Session("ProductList") & ") order by ID"
rs2.open sql2,conn,1,1
dim chicun,i
chicun=rs("chicun")
if chicun<>"" then
chicun=split(chicun, ",")
for i=0 to ubound(chicun)
%>
<option value="<%=chicun(i)%>"><%=chicun(i)%></option>
<%
next
end if
rs2.close
set rs2=nothing
%></select>
</td>
<td align="center" bgcolor="#FFFFFF"><input name="<%="Q_" & rs("ID")%>" type="text" value="<%=Quantity%>" size="4"
/></td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<tr>
<td height="40" colspan="5" align="center" bgcolor="#FAFDF9"><a href="index.asp"><img src="images/btn_continue.gif"
width="77" height="20" border="0" /></a> <input type="image" name="order"
src="images/btn_update.gif" width="63" height="20" border="0" style="curser:hand" /> <a
href="gouwu.asp?ProductList=ProductList"><img src="images/btn_clear.gif" width="63" height="20" border="0"
/></a> <a href="shouyin.asp"><img name="payment" src="images/btn_payment.gif" width="77"
height="20" border="0" /></a> <input type="hidden" name="update" value="update"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>