购物车程的规划.doc

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
购物车程的规划

一、购物车程序的规划 功能模块有:添加物品、删除物品、清空购物车、修改购买物品数量 在物品展示页面以物品的ID号为参数来运行JS函数PutWare(strID) PutWare(strID)函数内容如下: script language=JavaScript function PutWare(strID){ Shopwin=window.open(shopping.asp?action=addspid=+strID+PtCount=1,WareList,width=580,height=250,scrollbars=yes,resiza ble=yes); Shopwin.focus(); } /script 此函数功能,打开购物车shopping.asp并传传递当前页变量参数(acction,id,ptcount) 物品展示外的调用如下: 添加物品:a href=javascript:; onClick=PutWare(%=trim(rs(id))%)放入购物车/a 二、添加商品代码分析: % 添加商品 if request(action)=add then call AddProduct(request(spid),CInt(request(PtCount))) end if % 此段判断是否要放物品在购物车中,如果是的话,调用AddProduct(strPcID,intCount)过程,过程代码如下: % sub AddProduct(strPcID,intCount) ProductList = Session(ProductList)?? 商品ID列表 ProductCount=Session(ProductCount)?? 商品数量列表 Products = Split(ProductList, ,)?? 分割物品种类为数组 PtCounts = Split(ProductCount, ,)?? 分割物品数量为数组 下面为寻求购物车中是否有该商品,如果没有则追加 For i=0 To UBound(Products)返回Products的元素个数,及数组Products的最大的下标。 ??? if Products(i)=strPcID then exit for Next 还没有该商品,追加 if iUBound(Products) then ?? Session(ProductList) = ProductList strPcID , ?? Session(ProductCount) = ProductCount intCount , else ?? 如果商品已在车中,累加数量 ?? PtCounts(i)=Cint(PtCounts(i)) + intCount ?? Session(ProductList) =join(Products,,) ?? Session(ProductCount) =join(PtCounts,,)将数组转换成字串 end if end sub % 三、删除商品代码分析: 删除物品:input type=button name=Submit value=删除 onClick=DeleProduct(%=rs(id)%) % if request(action)=modiy then call ModifyProduct(request(spid),CInt(request(PtCount))) end if % 此段判断是否要删除购物车中的指定物品,如果是的话,调用ModifyProduct(strPcID,intCount)过程,过程代码如下: % sub ModifyProduct(strPcID,intCount) ProductList = Session(ProductList)?? 商品ID列表 ProductCount=Session(ProductCount)?? 商品数量列表 Products = Split(ProductList, ,) PtCounts = Split(ProductCount, ,) 寻求购物车中是否有该商品,如果有则删除 For i=0 To UBound(Products) if Products(i)=strPcID then exit for Next 还有该商品,删除该商品指定的数量 if i=UBound(Products) then PtCounts(i)=intCount?? if PtCounts(i) 0 then PtCounts(i)=0 防止溢出 end if 将数组转换成字串 Session(ProductList) =join(Products,,) Session(ProductC

文档评论(0)

jiaoyuguanliji + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档