?? cart_xt.asp
字號:
<%
'***********************************
'功能:實現(xiàn)購物車的原理
'調(diào)用方法:call cart(購買商品的ID號,單價,購買數(shù)量)
'輸出arr數(shù)組中的商品信息
'call cart("spid","price","spsl")
'arr=session("arr_xt")
'For I = 0 To ubound(arr,1)
' For J = 0 To 2
'response.Write(arr(I, J)&"|")
' Next
'response.Write("<br>")
'Next
'開發(fā)時間:2005-09-16 11:25
'開發(fā)者:王國輝
'***********************************
function cart(buyID,price,buynumber)
if not isarray(session("arr_xt")) then
dim arr(0,2)
arr(0,0)=buyID
arr(0,1)=price
arr(0,2)=buynumber
else
arr=session("arr_xt")
UB=ubound(arr,1)+1
redim arr(UB,2)
sessionarr=session("arr_xt")
'將新添加的商品信息保存
arr(UB,0)=buyID
arr(UB,1)=price
arr(UB,2)=buynumber
'應(yīng)用循環(huán)將保存在seesion("arr")數(shù)組中的商品信息添加到arr中
For I = 0 To ubound(sessionarr,1)
For J = 0 To 2
arr(I, J)=sessionarr(I,J)
Next
Next
end if
session("arr_xt")=arr
end function
'調(diào)用購物車函數(shù)并顯示購物車中的數(shù)據(jù)
'call cart("spid","spsl")
'arr=session("arr_xt")
'For I = 0 To ubound(arr,1)
' For J = 0 To 2
' response.Write(arr(I, J)&"|")
' Next
' response.Write("<br>")
'Next
'***********************************
'功能:實現(xiàn)購物車的原理
'調(diào)用方法:call remove(要刪除商品的ID號)
'開發(fā)時間:2005-09-16 16:57
'開發(fā)者:王國輝
'***********************************
function remove(spid)
if isarray(session("arr_xt")) then
arr=session("arr_xt")
UB=Ubound(arr,1)
if UB=0 then
session("arr_xt")=""
else
flag=false '標記是否已經(jīng)刪除對應(yīng)的商品信息
redim arr_temp(UB-1,2) '定義臨時存儲購物車信息的數(shù)組
for i=0 to UB
if arr(i,0)<>spid then
for j=0 to 2
if flag then '當刪除一條商品信息后
arr_temp(i-1,j)=arr(i,j)
else
arr_temp(i,j)=arr(i,j)
end if
next
else
flag=true
end if
next
end if
end if
session("arr_xt")=arr_temp
end function
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -