国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

購物車范例(處理頁面)

2019-11-18 20:26:08
字體:
來源:轉載
供稿:網友
<!--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_            

    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
%>


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东城区| 璧山县| 洛南县| 建水县| 卓尼县| 宜兰市| 屯昌县| 隆安县| 平阳县| 合作市| 岢岚县| 五华县| 汽车| 磐安县| 鸡泽县| 鹤壁市| 通江县| 山阴县| 富阳市| 通河县| 顺昌县| 丹东市| 西乌珠穆沁旗| 阿尔山市| 兴化市| 江孜县| 鹤山市| 外汇| 公安县| 栾城县| 汉寿县| 芮城县| 含山县| 杂多县| 新邵县| 贵州省| 仁化县| 乌拉特后旗| 图片| 惠来县| 徐汇区|