📄 check.asp
字号:
<style type="text/css">
<!--
body,td,th {
color: #000000;
}
body {
background-color: #F4F4F4;
}
a:link {
color: #003399;
}
a:visited {
color: #003399;
}
a:hover {
color: #003399;
}
a:active {
color: #003399;
}
-->
</style>
<%
response.buffer = true
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("shop.mdb")
if request("change") <>"" then '表单已提交
productlist = "" '
products = split(request("productid"), ", ")
'products是用来保存所有已选购的商品编号的数组
for i=0 to ubound(products)
if len(productlist) = 0 then
productlist = "'" & products(i) & "'"
elseif instr( productlist, products(i) ) <= 0 then
productlist = productlist & ", '" & products(i) & "'"
end if
quatity = clng( request( "q_" & products(i) ) ) '获取商品数量文本框中的值
if quatity <= 0 then
productid = request.cookies( products(i) )
if productid = "" then productid = empty
quatity = clng( productid )
end if
if quatity <= 0 then quatity = 1
response.cookies( products(i) ) = quatity
next
response.cookies("productlist") = productlist
end if
productlist = request.cookies("productlist")
if len(productlist) = 0 then '如果cookie为空,则调用nothingbuy过程
call nothingbuy
response.end
end if
set rs=server.createobject("adodb.recordset")
sql = "select * from products"
sql = sql & " where productid in (" & productlist & ")"
sql = sql & " order by productid"
rs.open sql,conn
%>
<html>
<head><title>查看购物车</title></head>
<body>
<h3 align=center>以下是您所选购的商品清单<hr></h3>
<center>
<form action=check.asp method=post>
<table border=1>
<tr bgcolor=#FFFFCC>
<td>确认</td><td>商品编号</td><td>商品名称</td><td>单价</td><td>数量</td><td>总价</td><td>商品简介</td></tr>
<%
sum = 0
while not rs.eof
quatity = request.cookies(rs("productid"))
if quatity = "" then quatity = 1
sum = sum + cdbl(rs("price")) * quatity
%>
<tr>
<td align=center>
<input type=checkbox name="productid" value="<%=rs("productid")%>" checked>
</td>
<td><%=rs("productid")%></td>
<td><%=rs("productname")%></td>
<td align=right><%=rs("price")%></td>
<td><input type=text name="<%="q_" & rs("productid")%>" value=<%=quatity%> size=3></td>
<td align=right><%=cdbl(rs("price"))*quatity%></td>
<td><a href=<%=rs("image")%>><%=rs("description")%></a></td>
</tr>
<%
rs.movenext
wend
%>
<tr><td align=right colspan=7><font color=red>总价格=<%=sum%></font></td></tr>
</table>
<input type=submit value=" 更改商品数量 " name="change">
<a href="clear.asp">清空购物车</a> <a href="bill.asp">结帐</a><p>
</form>
<hr>
选择购物区:
<%
for i = 1 to request.cookies("categorylinks")
response.write request.cookies( "categorylink" & i ) & " "
next
%>
</center>
</body>
</html>
<% sub nothingbuy()
%>
<html>
<head><title>查看购物车</title></head>
<body>
<h2 align=center>您尚未选购任何商品 或是 退回了所有商品!<hr></h2>
<center>
<%
for i = 1 to request.cookies("categorylinks")
response.write request.cookies( "categorylink" & i ) & " "
next
%>
</center>
</body>
</html>
<% end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -