实验6-1 利用ASP Session实现购物车功能

2026/4/28 16:20:15

实验6-1 利用会话实现购物车功能

1 在站点下建立一个Global.asa文件,中输入以下的内容(若该文件存在的话,则添加以下的内容):

SUB Session_OnStart

Session(\ Session(\

Session(\用于存放购物车内的货物数 ReDim arrcart(50,3)

Session(\二维数组用于存放货物名称 END SUB

SUB Session_OnEnd

set Session(\ set Session(\ set Session(\ set Session(\END SUB

说明:Global.asa 文件是一个可选的文件,它可包含可被 ASP 应用程序中每个页面访问的对象、变量

以及方法的声明。Global.asa 文件须存放于 ASP 应用程序的根目录中,且每个应用程序只能有一个 Global.asa 文件。详细内容参见

http://www.w3school.com.cn/asp/asp_globalasa.asp

2 建立挑选商品网页mechase.html,内容如下:

挑选商品

购买数量

3 建立放入购物车网页addcart.asp,内容如下:

放入购物车 <%

arrCart=Session(\CartIndex=Session(\count=0

for i=0 to CartIndex if arrCart(i,2)<>\ if arrCart(i,2)>0 then count=count+1 end if end if next

'count中为统计出的购物车中所购商品的总数,用于价格计算

idbook=request(\bookname=request(\quantity=request(\if quantity<>\ quantity=Cint(quantity)

'newprice=查询数据库来计算新的价格

if quantity>0 then

arrCart(CartIndex,0)=idbook arrCart(CartIndex,1)=bookname arrCart(CartIndex,2)=quantity 'arrCart(CartIndex,3)=newprice Session(\ Session(\

response.redirect \ end if else

response.write \你没有选择购买数量!\end if %>

转到显示购物车内容的网页


实验6-1 利用ASP Session实现购物车功能.doc 将本文的Word文档下载到电脑
搜索更多关于: 实验6-1 利用ASP Session实现购物车功能 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219