• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: 小 中 大 | 推荐给好友 上一篇 | 下一篇

购物车范例(转)(处理页面)

发布: 2007-6-30 18:56 | 作者: admin | 来源: | 查看: 13次 | 进入软件测试论坛讨论

领测软件测试网 <!--put2bag.asp-->

<%@ Language=VBScript %>
<%
    ‘’id_type=request("id_type")

    on error resume next
    Response.Buffer = true
    Response.Expires = 0
    dim obj_bag,bag_item,cart
            ‘’obj_bag      ----购物车
            ‘’bag_item     ----商品的信息数据集合
            ‘’cart         ----一件商品的信息数据集合
    dim p_id,p_name,p_price,p_manu,p_type,p_size,p_color,p_num,p_temp
            ‘’p_id               ----商品id号
            ‘’p_name          ----商品名称
            ‘’p_price           ----原价单价
            ‘’p_manu          ----商品制造商
            ‘’p_type            ----商品式样
            ‘’p_size            ----商品尺寸
            ‘’p_color           ----商品颜色
            ‘’p_num            ----商品数量
            ‘’p_temp           ----临时存放p_num
            

    if session("login")="" then
        response.write"<script langue=""javascript"">" & chr(13)
        response.write"alert(""请先登录"");" & chr(13)
        response.write"history.go(-1);" & chr(13)
        response.write"</script>" & chr(13)
    else
                ‘’初始化购物车内变量
        p_id=trim(request("id"))
        P_manu=trim(request("manu"))
        p_type=trim(request("type"))
        p_name=replace(trim(request("name1"))," ","")
        p_price=trim(request("price"))
        p_size=trim(request("size"))
        p_color=trim(request("color"))
        p_num=trim(request("num"))

        if ((not IsNumeric(p_num)) or (p_num<="0") or (instr(1,p_num,".")<>0)) then
            p_num=1                 ‘如果商品数量小于0或者有小数点,取1
        end if
        
        if p_name <>"" then
                        ‘’如果有购物信息传入则准备装如购物车
                        ‘’如果还没有购物车则新建dictionary对象

            if isobject(Session("Bag")) then   ‘’如果有购物车则更新
            ‘’response.write "isobject(Session(""Bag""))=" & isobject(Session("Bag")) & "<br>"
                set obj_bag=Session("Bag")
                if obj_bag.exists(p_name) then      ‘’‘’如果当前购物车中已有该商品
                    if err then
                        response.write err.description
                        err.clear
                    end if
                    
                    ‘’response.write isobject(obj_Bag)

                    p_temp=obj_bag.item(p_name)(6) ‘’将p_num的值存放于p_temp中
                    response.write "p_num=" & p_num & "<br>"
                    p_num=cint(p_num)+cint(p_temp)  ‘’购买的商品数量累加
              
                    bag_item=array(p_name,p_manu,p_type,p_size,p_color,p_price,p_num,p_id)
                    obj_bag.item(p_name)=bag_item
                 else                       
                    bag_item=array(p_name,p_manu,p_type,p_size,p_color,p_price,p_num,p_id)
                    obj_bag.Add p_name,bag_item
                end if
          
            else                                                      ‘’没有购物车生成新的
                set obj_bag=server.CreateObject ("Scripting.Dictionary")
                bag_item=array(p_name,p_manu,p_type,p_size,p_color,p_price,p_num,p_id)
                response.write bag_item(0)
                obj_bag.Add p_name,bag_item
            end if   
            set Session("Bag") = obj_Bag    ‘’更新购物车
        end if
        
        Response.Redirect ("checkbag.asp?obj="& request("obj") &"") ‘’转向显示购物车页面
    end if
%>


延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:[email protected] 电话:010-51297073

软件测试 | 领测国际 | ISTQB | ISTQB官网 | TMMi | TMMi认证 | 国际软件测试工程师认证 | 领测软件测试网