if obj="1" then obj为1说明由菜单栏点击进入的 if not isobject(Session("Bag")) then 如果Session("Bag")不是对象,说明购物车为空 response.write "<script language=""javascript"">" response.write"alert(""购物车为空!"");" & chr(13) response.write "window.location='index.asp'" response.write "</script>" response.end else set obj_bag=Session("Bag") 若购物车不为空,将它赋给对象obj_bag end if else if isobject(Session("Bag")) then 若不是菜单栏点击进入的,则将购物车信息赋给对象obj_bag
set obj_bag=Session("Bag") else 若购物车为空,说明购物车内没有商品,则返回首页 response.write "<script language=""Javascript"">" response.write"alert(""T购物车为空!"");" & chr(13) response.write "window.location='index.asp'" response.write "</script>" response.end end if end if 'response.write "<script>alert("""& isobject(obj_bag) &""")</script>"
select case request("action") 取得按钮信息 如果选择刷新则重新计算商品的价值及总价 将当前信息计算写入购物车并显示购物车 case "refresh" 若为刷新 for each cart in obj_bag.items p_name=cart(0) 将购物车中的信息数据集合分别赋值给变量 p_manu=cart(1) p_type=cart(2) p_size=cart(3) p_color=cart(4) p_price=cart(5) p_num=cart(6) p_id=cart(7)
if request("checkBox_" & p_id)<>"" then 取得取消单选框的值,如果不为空,即打钩 if obj_bag.Exists(p_name) then 如果商品已存在删除该商品 obj_bag.remove(p_name) end if else p_num=trim(request("quantity"&p_name)) 若没有该操作,写入购物车 if ((not IsNumeric(p_num)) or (p_num<="0") or (instr(1,p_num,".")<>0)) then p_num=1 end if bag_item=array(p_name,p_manu,p_type,p_size,p_color,p_price,p_num,p_id) 'response.write "p_num=" & p_num & "<br>" end if next set Session("Bag")=obj_bag 将obj_bag对象里的信息,写入Session("Bag")
如果选择去收银台则准备开始接收付款 将当前信息写入购物车并转向收银程序 case "check" 按钮为购买的时候 for each cart in obj_bag.items 循环cart将其所有信息都赋给变量 p_name=cart(0) p_manu=cart(1) p_type=cart(2) p_size=cart(3) p_color=cart(4) p_price=cart(5) p_num=cart(6) p_id=cart(7)
if request("checkBox_" & p_id)="" then 如果取消单选框为空,取id1的值 id1=p_id & "," & id1 将他们有逗号形式连接 end if next id1=left(id1,len(id1)-1) shopping_id=request("id") set obj_bag=session("bag") set session("obj_bag")=obj_bag call insertDB(id1) 调用函数 end select %> '输出HTML 。。。。。。。。。(略)