當前位置:編程學習大全網 - 源碼下載 - 請問asp網頁購物車代碼中的如下代碼如何解釋啊,求幫助啊!<% public ProductList if request("order")="產

請問asp網頁購物車代碼中的如下代碼如何解釋啊,求幫助啊!<% public ProductList if request("order")="產

直接上代碼註釋:

<%

'Session("ProductList") 是購物車

'ProductList 購物車臨時變量 用於處理購物車裏的商品

public ProductList '定義商品列表

if request("order")="產品更新" then '判斷傳過來的order參數 如果是產品更新

Session("ProductList")="" ' 清空購物車商品列表

end if

'以下是非產品更新情況下 取決於頁面參數 order

ProductList = Session("ProductList") '把購物車裏的產品列表給Productlist變量

'壹個過程 作用想購物車裏添加產品

Sub PutToShopBag(Prodid, ProductList) '參數:產品ID,購物車產品列表

If Len(ProductList) = 0 Then '如果購物車為空

ProductList = "'" & Trim(Prodid) & "'" '直接把要添加的商品給購物車 這是第壹件商品

ElseIf InStr( ProductList, Prodid ) <= 0 Then ' 如果購物車裏有商品

ProductList = ProductList&", '"&Trim(Prodid)&"'" '則把要添加的商品ID追加到最後 並用逗號隔開

End If

End Sub '過程結束

Product_Id = Trim(Request("Product_Id")) '接受傳過來的商品ID參數 即要添加進購物車的商品ID

if instr(Product_Id,",")>0 then '如果這不是壹件商品而是用逗號分隔開的幾件商品

idArr=Split(Product_Id, ",") '則把參數 Product_Id 以逗號為分隔符分割成熟組

for i = 0 to ubound(idArr) '遍歷數組把這幾件商品追加進購物車

PutToShopBag idArr(I), ProductList

next '追加完畢

else

PutToShopBag Product_Id, ProductList '如果是壹件商品 則直接調用上面的那個過程追加商品至購物車

end if

Session("ProductList") = ProductList '把操作完的臨時購物車變量ProductList 給購物車

if Productlist<>"''" then '如果購物車不為空 則計算購物車裏的商品總價 通過sql語句調用數據庫裏的價格字段計算

sql="select * from Product where Product_Id in ("&ProductList&") order by Product_Id"

Set rs_price = conn.Execute(sql)

else '如果購物車為空

response.redirect "error.asp?error=007" '則跳轉到錯誤頁面

response.end '停止執行下面的代碼

end if '結束

%>

  • 上一篇:用什麽公式自由移動同花順主要指標的垂直線?
  • 下一篇:開源軟件的特點包括
  • copyright 2024編程學習大全網