中文字幕在线一区二区在线,久久久精品免费观看国产,无码日日模日日碰夜夜爽,天堂av在线最新版在线,日韩美精品无码一本二本三本,麻豆精品三级国产国语,精品无码AⅤ片,国产区在线观看视频

      asp購(gòu)物車代碼

      時(shí)間:2024-09-18 01:36:55 ASP 我要投稿
      • 相關(guān)推薦

      asp購(gòu)物車代碼

        asp購(gòu)物車代碼怎么寫?為幫助大家順利寫出ASP購(gòu)物車的源代碼,本文yjbys小編主要介紹了ASP購(gòu)物車實(shí)現(xiàn)過(guò)程,需要的朋友可以參考下!

        asp購(gòu)物車代碼

        cart.asp代碼如下

        <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

        <html xmlns="http://www.w3.org/1999/xhtml">

        <head>

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

        <title>無(wú)標(biāo)題文檔</title>

        <script type="text/javascript" src="js/jquery.js"></script>

        <style type="text/css">

        a{text-decoration:none;}

        td,p{font-size:12px}

        </style>

        </head>

        <body>

        <%

        dim action,bookid,aProducts,delid,i,conn,rs,sql,sNewProducts

        set conn = Server.CreateObject("adodb.connection")

        conn.connectionstring="provider=microsoft.jet.oledb.4.0;data source="&server.MapPath("#dbFB90.Mdb")

        conn.open

        action=Request.QueryString("action")

        if Request.QueryString("id")="" then

        bookid=Session("productlist")'//////////////////////////////////調(diào)入查詢物品的id

        else

        if Session("productlist")="" then

        Session("productlist")=Request.QueryString("id")

        bookid=Request.QueryString("id")

        else

        if InStr(Session("productlist"),Request.QueryString("id"))<1 then

        bookid=Session("productlist")+","+Request.QueryString("id")'//////////////把id全部存儲(chǔ)到bookid中類似與數(shù)組

        Session("productlist")=bookid

        else

        bookid=Session("productlist")

        end if

        end if

        end if

        if Session("productlist")="" then'////////////////////////若id為空,則說(shuō)明用戶沒有購(gòu)物

        bookid=0

        end if

        if action="del" then '刪除購(gòu)物車中的某一件商品

        aProducts=Split(Session("ProductList"),",")

        delid=CStr(Trim(Request.QueryString("id")))

        For i=0 To UBound(aProducts)    '循環(huán)所有商品ID

        If trim(aProducts(i))<>delid then

        '不等于被刪除的ID時(shí)則保存進(jìn)新的列表中

        sNewProducts = sNewProducts & "," & aProducts(i)

        end if

        Next

        Session("ProductList") = mid(sNewProducts,2)

        if Session("ProductList")="" then

        bookid=0

        else

        bookid=Session("ProductList")

        end if

        elseif action="delall" then

        Session("ProductList")=""

        response.Redirect("cart.asp")

        end if

        %>

        <form name="myform" method="post" action="cart.asp">

        <input type="hidden" name="id" value="<%= bookid %>" />

        <table width="90%" border="1" cellspacing="5" cellpadding="3" style="border-collapse:collapse; margin-bottom:20px;">

        <tr>

        <td align="center">商品id</td>

        <td align="center">商品名稱</td>

        <td align="center">商品單價(jià)</td>

        <td align="center">訂購(gòu)數(shù)量</td>

        <td align="center">商品金額</td>

        <td align="center">操作</td>

        </tr>

        <%

        '根據(jù)臨時(shí)存儲(chǔ)到Session里的商品ID分別從商品數(shù)據(jù)庫(kù)循環(huán)調(diào)出商品顯示到購(gòu)物車頁(yè)面,遇到重復(fù)ID不顯示

        Dim Quatity,sum,aa '判斷input 名

        sum=0

        if bookid<>0 and bookid<>"" then

        set rs=Server.CreateObject("adodb.recordset")

        sql="select id,product_name,price,info from product where id in ("&bookid&") order by id" '這里替換成實(shí)際的商品數(shù)據(jù)庫(kù)及字段

        rs.open sql,conn,1,1

        if not (rs.eof and rs.bof) then

        aa=1

        Do While Not rs.EOF

        Quatity = CInt(Request("sl"&aa))

        If Quatity <=0 Then Quatity = 1 '以下為購(gòu)物車每一件商品內(nèi)容,包含ID、名稱、數(shù)量及取消

        %>

        <tr>

        <td align="center"><%=rs("id")%></td>

        <td align="center"><a href="showproduct.asp?id=<%=rs("id")%>" title="<%=rs("info")%>" target="_blank"><%=rs("product_name")%></a></td>

        <td align="center"><span id="unitprice<%= aa %>"><%=rs("price")%></span></td>

        <td align="center">

        <input type="hidden" id="itemId<%= aa %>" value="<%= rs("id") %>" />

        <input type="button" value="-" onclick="myfun(1,'<%= aa %>')" />

        <input name="sl<%=aa%>" id="sl<%= aa %>" type="text" value="<%= Quatity %>" size="3" readonly="readonly" />

        <input type="button" value="+" onclick="myfun(2,'<%= aa %>')" /></td>

        <td align="center"><span id="total<%= aa %>"><%=(rs("price")*Quatity)%></span></td>

        <td align="center"><a href="?id=<%=rs("id")%>&action=del"><font color="#FF0000" size="4" style="font-weight:bold">×</font></a></td>

        </tr>

        <%'循環(huán)讀取ASP購(gòu)物車內(nèi)的商品

        sum=FormatNumber(rs("price")*Quatity+sum,2)

        rs.movenext

        aa=aa+1

        Loop

        else

        response.Write("<tr><td align='center' colspan='6'>暫無(wú)選購(gòu)的商品,請(qǐng)繼續(xù)<a href='products.asp'>購(gòu)物</a></td></tr>")

        end if

        rs.close

        set rs=nothing

        Else

        response.Write("<tr><td align='center' colspan='6'>暫無(wú)選購(gòu)的商品,請(qǐng)繼續(xù)<a href='products.asp'>購(gòu)物</a></td></tr>")

        end if

        conn.close

        set conn=nothing

        %>

        </table>

        </form>

        <p style="text-align:right; width:90%">

        <input type="button" value="清空購(gòu)物車" onclick="if(confirm('確定要清空購(gòu)物車么?')){window.location.href='?action=delall';}" />

        總價(jià):<span id="tcount"><%= sum %></span>元

        <input type="button" value="繼續(xù)購(gòu)物" onclick="window.location.href='products.asp';" />

        <input type="button" value="立即結(jié)算" onclick="nextStep();" />

        </p>

        <script type="text/javascript">

        function round(v,e){

        var t=1;

        for(;e>0;t*=10,e--);

        for(;e<0;t/=10,e++);

        return Math.round(v*t)/t;

        }

        function myfun(str,obj){

        var quantity,sum=0;

        if(str==1){

        if(document.getElementById("sl"+obj).value>1){

        document.getElementById("sl"+obj).value--;

        }

        }

        else{

        document.getElementById("sl"+obj).value++;

        }

        quantity=$("#sl"+obj).val();

        $("#total"+obj).text(round($("#unitprice"+obj).text()*quantity,2));

        for(var i=1;i<<%= aa %>;i++){

        sum+=round($("#total"+i).text(),2);

        }

        sum=round(sum,2);

        $("#tcount").text(sum);

        var strTemp;

        for(var j=1;j<<%= aa %>;j++){

        if(j==1){

        strTemp=$("#itemId"+j).val()+"|"+$("#sl"+j).val()+"|"+$("#total"+j).text();

        }

        else{

        strTemp+="#"+$("#itemId"+j).val()+"|"+$("#sl"+j).val()+"|"+$("#total"+j).text();

        }

        }

        //alert(strTemp);

        }

        function nextStep(){

        var strTemp;

        for(var j=1;j<<%= aa %>;j++){

        if(j==1){

        strTemp=$("#itemId"+j).val()+"|"+$("#sl"+j).val()+"|"+$("#total"+j).text();

        }

        else{

        strTemp+="#"+$("#itemId"+j).val()+"|"+$("#sl"+j).val()+"|"+$("#total"+j).text();

        }

        }

        $.post("saveData.asp",{str:strTemp,rnd:new Date().getTime()},function(msg){alert(msg);})

        }

        </script>

        </body>

        </html>

        saveData.asp 如下代碼:

        <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

        <%

        dim conn,str,i,strArr,arrstr

        set conn = Server.CreateObject("adodb.connection")

        conn.connectionstring="provider=microsoft.jet.oledb.4.0;data source="&server.MapPath("#dbFB90.Mdb")

        conn.open

        str=request.Form("str")

        strArr=split(str,"#")

        for i=0 to ubound(strArr)

        arrstr=split(strArr(i),"|")

        conn.execute("insert into [orders](productId,Quantity,total) values("&arrstr(0)&","&arrstr(1)&","&arrstr(2)&")")

        next

        response.Write("success")

        conn.close

        set conn=nothing

        %>

      【asp購(gòu)物車代碼】相關(guān)文章:

      asp緩存類代碼09-28

      asp獲取當(dāng)前URL代碼實(shí)例10-14

      關(guān)于ASP模板類代碼參考08-29

      asp.net 組合模式的PHP代碼10-07

      防盜鏈接ASP函數(shù)實(shí)現(xiàn)代碼08-03

      關(guān)于ASP讀取IIS日志的小程序代碼08-29

      asp.net動(dòng)態(tài)獲取Excel表名的代碼10-12

      asp.net 操作INI文件讀寫類實(shí)例代碼07-28

      asp.net 動(dòng)態(tài)引用樣式表代碼示范06-14

      ASP.NET連SQL7接口的源代碼06-06

      主站蜘蛛池模板: 精品一区二区三区四区少妇| 国产中文字幕乱码在线| 国产在视频线精品视频二代| 仪征市| 久久精品国产亚洲AV古装片| 女人高潮被爽到呻吟观看| 亚洲中文字幕有综合久久| 91精品国产91久久久无码色戒| 拉萨市| 女同久久一区二区三区| 日本在线视频观看二区| 谁有在线观看av中文| 精品黑人一区二区三区| 国产精品亚洲综合色区丝瓜| 扎鲁特旗| 久久AⅤ无码精品色午麻豆| 台江县| 广元市| 广平县| 狠狠一本天堂亚洲综合十八禁| 97人妻蜜臀中文字幕| 国产精品毛片99久久久久| 池州市| 国产亚洲人成在线影院| 国产成品精品午夜视频| 丹阳市| 国产在线h视频| 成美女黄网站18禁免费| 国产精品nv在线观看| 国产一区二区三区资源在线观看| 午夜无码国产18禁| 特级毛片a级毛片在线播放www | 精品国产亚洲av成人一区| 日韩无码电影| www久久久888| 国产午夜精品美女裸身视频69| 亚洲av永久无码精品成人| 精品人妻丰满久久久a| 亚洲99一区二区三区| 偷拍视频网站一区二区| 精品人妻少妇一区二区中文字幕|