<%response.expires=0%>
<%
写入cookie
response.write request.cookies("warebuycount")
sub setcookie(aname,warenum,warename,price,warecount,pricelow)
response.cookies(aname).domain=application("wareurl") wareurl代表域名
response.cookies(aname).expires=date()+30 cookie过期日期
response.cookies(aname).path="/"
response.cookies(aname).secure = false
response.cookies(aname)("warenum")=warenum 商品编号
response.cookies(aname)("warename")=warename 商品名称
response.cookies(aname)("price")=price 价格
response.cookies(aname)("warecount")=warecount 购买的数量
response.cookies(aname)("pricelow")=pricelow 会员价格
end sub
sub setcount(warebuycount) 用于计算客户购买的商品种类
response.cookies("warebuycount").domain=application("wareurl")
response.cookies("warebuycount").expires=date()+30
response.cookies("warebuycount").path="/"
response.cookies("warebuycount").secure=false
response.cookies("warebuycount")=warebuycount
end sub
写入cookies
sub setcookies(warenum,warename,price,warecount,pricelow,warebuycount)
setcookie "warenum"+cstr(warebuycount),warenum,warename,price,warecount,pricelow
end sub
sub delcookies(delwarenum)
warebuycount=request("warebuycount")-1
while cint(delwarenum)<=cint(warebuycount)
setcookies request.cookies("warenum"+cstr(delwarenum+1))("warenum"),request.cookies("warenum"+cstr(delwarenum+1))("warename"),request.cookies("warenum"+cstr(delwarenum+1))("price"),request.cookies("warenum"+cstr(delwarenum+1))("warecount"),request.cookies("warenum"+cstr(delwarenum+1))("pricelow"),delwarenum
delwarenum=delwarenum+1
wend
setcount warebuycount
end sub
warenum=request.querystring("warenum") 从get返回的商品编号,当然,这个商品也一定要存在于你的商品表中
warename=request.querystring("warename") 从get返回的商品名称
price=request.querystring("price") 价格
warecount=request.querystring("warecount") 购买数量
pricelow=request.querystring("pricelow") 会员价格
setcount 4
warebuycount=request.cookies("warebuycount")
response.write warebuycount
if request.servervariables("request_method")="post" then
dum=request("del")
dim delnum
delnum=split(dum,",")
t1=1
warebuycount=request.cookies("warebuycount")
while t1<=cint(warebuycount)
tm=request("warenum"+cstr(t1))
rm="warenum"+cstr(t1)
nomodi=false
if tm="" then
tm=0
end if
if instr(1,cstr(tm),".") or tm=0 then
nomodi=true
else
setcookies request.cookies("warenum"+cstr(t1))("warenum"),request.cookies("warenum"+cstr(t1))("warename"),request.cookies("warenum"+cstr(t1))("price"),tm,request.cookies("warenum"+cstr(t1))("pricelow"),t1
end if
t1=t1+1
wend
if dum<>"" then
cwarenum=0
while cwarenum<=ubound(delnum)
delcookies delnum(cwarenum)-cwarenum
cwarenum=cwarenum+1
wend
setcount request.cookies("warebuycount")-(ubound(delnum)+1)
end if
else
if warenum<>"" then
warebuycount=request.cookies("warebuycount")
if warebuycount="" then
warebuycount=0
else
if warebuycount<0 then
warebuycount=0
end if
end if
i=1
allready=false
response.write warebuycount
response.end
while i<=cint(warebuycount)
tsf="warenum"+trim(cstr(i))
if request.cookies(tsf)("warenum")=warenum then
allready=true
mut=request.cookies(tsf)("warecount")
mtp=i
end if
i=i+1
wend
if allready=false then
warebuycount=warebuycount+1
end if
if pricelow="" then
pricelow=0
end if
if allready=false then
setcookies warenum,warename,price,warecount,pricelow,warebuycount
else
setcookies warenum,warename,price,warecount+cint(mut),pricelow,mtp
end if
setcount warebuycount
end if
end if
t=1
while t<20
setcookies "warenum"+cstr(t),"","","","",""
t=t+1
wend
setcount 0
response.write request.cookies("warebuycount")
response.end
warebuycount=request.cookies("warebuycount")
response.write warebuycount
response.write request.cookies("warenum1")+"+"
response.write request.cookies("warenum2")+"+"
response.write request.cookies("warenum3")+"+"
response.write request.cookies("warenum4")+"+"
response.write "fdas"
response.write request.cookies("warebuycount")
response.end
response.write warebuycount
response.write request.cookies("price1")
检测客户端是否打开cookie功能
response.cookies("checkcookie").domain=application("wareurl")
response.cookies("checkcookie").expires=date()+30
response.cookies("checkcookie").path="/"
response.cookies("checkcookie").secure = false
response.cookies("checkcookie")="ok"
if request.cookies("checkcookie")="" then
response.write "你的浏览器不支持cookie功能或者你没有启用cookie能,请你先进行设置然后再购买商品,谢谢!"
response.end
end if
%>
<html>
<head>
<script language=javascript>
<!--
function wopen(){
window.open("warejs.asp","warejs","menubar=yes,toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=1,resizable=0,width=800,top=0,left=0,height=500");
window.close();
}
-->
</script>
<meta name="generator" content="microsoft frontpage 3.0">
<title>购物车</title>
<link rel="stylesheet" type="text/css" href="boyi-sheet.css">
</head>
<body>
<% response.write warebuycount%>
<table border="0" width="100%" cellspacing="1" cellpadding="4" bgcolor="#ffc184"
height="82">
<tr>
<td width="12%" bgcolor="#008080" style="color: rgb(255,255,255)" align="middle" nowrap
height="14">商品名称</td>
<td width="12%" bgcolor="#008080" style="color: rgb(255,255,255)" align="middle" nowrap
height="14">零售价</td>
<td width="12%" bgcolor="#008080" style="color: rgb(255,255,255)" align="middle" nowrap
height="14">会员价</td>
<td width="12%" bgcolor="#008080" style="color: rgb(255,255,255)" align="middle" nowrap
height="14">数量</td>
<td width="13%" bgcolor="#008080" style="color: rgb(255,255,255)" align="middle" nowrap
height="14">零售价小计</td>
<td width="13%" bgcolor="#008080" style="color: rgb(255,255,255)" align="middle" nowrap
height="14">会员价小计</td>
<td width="13%" bgcolor="#008080" style="color: rgb(255,255,255)" align="middle" nowrap
height="14">取消购买</td>
</tr><form action="lookware.asp" name="modiware" method="post" ><input type=hidden name="warecount" value="<%=warebuycount%>">
<%
tcou=1
pricetot=0
pricelowtot=0
response.write warebuycount
while tcou<=cint(warebuycount) %>
<tr>
<td width="12%" bgcolor="#f5fade" align="middle" nowrap height="25"><%if tcou=warebuycount then%><font color=red><%end if%><%=request.cookies("warenum"+cstr(tcou))("warename")%><%if tcou=warebuycount then%><font color=red><%end if%></td>
<td width="12%" bgcolor="#f5fade" align="middle" nowrap height="25"><p align="left"><font
color="red">¥</font><%=request.cookies("warenum"+cstr(tcou))("price")%></p></td>
<td width="12%" bgcolor="#f5fade" align="middle" nowrap height="25"><font color="red"><p
align="left">¥</font><%=request.cookies("warenum"+cstr(tcou))("pricelow")%></p></td>
<td width="12%" bgcolor="#f5fade" align="middle" nowrap height="25"><input id="text1"
name="<%="warenum"+cstr(tcou)%>" style="height: 22px; width: 33px" value="<%=request.cookies("warenum"+cstr(tcou))("warecount")%>"></td>
<td width="13%" bgcolor="#f5fade" align="middle" nowrap height="25"><p align="left"><font
color="red">¥</font><%=request.cookies("warenum"+cstr(tcou))("price")*request.cookies("warenum"+cstr(tcou))("warecount")%></p></td>
<td width="13%" bgcolor="#f5fade" align="middle" nowrap height="25"><p align="left"><font
color="red">¥</font><%=request.cookies("warenum"+cstr(tcou))("pricelow")*request.cookies("warenum"+cstr(tcou))("warecount")%></p></td>
<td width="13%" bgcolor="#f5fade" align="middle" nowrap height="25"><input id="checkbox1"
name="del" type="checkbox" value="<%=cstr(tcou)%>"> </td>
</tr><%
pricetot=pricetot+request.cookies("warenum"+cstr(tcou))("price")*request.cookies("warenum"+cstr(tcou))("warecount")
response.write request.cookies("warenum"+cstr(tcou))("price")
pricelowtot=pricelowtot+request.cookies("warenum"+cstr(tcou))("pricelow")*request.cookies("warenum"+cstr(tcou))("warecount")
tcou=tcou+1
response.write tcou
response.write warebuycount
wend%>
<tr>
<td width="63%" bgcolor="#f5fade" align="right" nowrap height="25" colspan="4">总计:</td>
<td width="13%" bgcolor="#f5fade" align="middle" nowrap height="25"><p align="left"><font color="red">¥</font><%=pricetot%></td>
<td width="13%" bgcolor="#f5fade" align="middle" nowrap height="25"><p align="left"><font color="red">¥</font><%=pricelowtot%></td>
<td width="13%" bgcolor="#f5fade" align="middle" nowrap height="25"><p align="left"></td>
</tr>
<tr>
<td width="87%" align="middle" nowrap height="13" colspan="7" bgcolor="#f5fade"><table
border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="19%" align="middle"><input id=button1 name=button1 style="background-color: orange; height: 24px; width: 58px" type=button value=继续购物 onclick="window.close()"></td>
<td width="20%" align="middle"><input id=button2 name=button2 style="background-color: orange; height: 24px; width: 59px" type=submit value=修改数量></td>
<td width="20%" align="middle"><input id=button3 name=button3 style="background-color: orange; height: 24px; width: 58px" type=submit value=取消购买></td>
<td width="20%" align="middle"><input id=button4 name=button4 style="background-color: orange; height: 24px; width: 60px" type=button value=清空购物车 onclick="javascript:document.location=clearcar.asp"></td>
<td width="20%" align="middle"><input id=button5 name=button5 style="background-color: orange; height: 24px; width: 56px" type=button value=去收银台 onclick="javascript:wopen()"></td>
</tr>
</table>
</td>
</tr></form>
<tr>
<td width="87%" align="middle" nowrap height="13" colspan="7" bgcolor="#f5fade"><font color=red><%if nomodi=true then%>商品数量修改失败!请输入正确的数字。<%else%>数据修改成功!<%end if%></font></td></tr>
</table>
</body>
</html>
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!


