[求助][难题]DUDU原谅,问题绝非一般,所以放在首页,让各位高手前辈赐教

' 更新购物车
sub  UpdateCart(key,value)
    cart.item(key)
= value
end sub


' 从购物车中减掉
sub  RemoveItemFromCart(key)
    
if  cart.exists(key)  then
        response.write cart.exists(key)
        cart.remove(key)
    
end   if
end sub

' 批量移除
sub  BatchRemoveCart(keyString)
    
dim  keys,itemkey,i,m
    keys
= split (keyString, " , " )
    m
= ubound (keys)
    
for  i = 0   to  m
        RemoveItemFromCart keys(i)
    
next
end sub

' 输出
sub  OutputCart()
    
for   each  key in cart.keys
        response.write key
& " = " & cart.item(key) & typename (key) & " <br> "
    
next
end sub

' 清空
sub  ClearCart()
    cart.removeall
end sub

' 由分隔的key/value字符串更新购物车
sub  BatchUpdateCart(keyString,valueString)
    
dim  keys,values,itemkey,i,n,t
    keys
= split (keyString, " , " )
    values
= split (valueString, " , " )    
    m
= ubound (keys)    
    n
= ubound (values)
    
for  i = 0   to  m
        
if  i > then  t = 1   else  t = values(i)
        UpdateCart keys(i),t
    
next
end sub

' 由dictionary转换为字符串
function  GetKeyString()
    
dim  keys
    keys
= ""
    
if  cart.count > 0   then     
    
for   each  key in cart.keys
        keys
= keys & key & " , "
    
next
    keys
= mid (keys, 1 , len (keys) - 1 )
    
end   if
    GetKeyString
= keys
end function

' 取其中一个值
function  GetCartItem(key)
    t
= cart.item(key)
    GetCartItem
= t
end function

以上是我在做的一个项目中购物车的实现,其中cart是一个定义在global.asa中的session scope变量,类型为:dictionary
但就是这个dictionary,把我搞晕了
主要是在处理购物车中产品移除时
productidlist=request("ProductIdList").item
得到CHECKBOX 的值,形式是一个逗号分隔的产品ID列表
然后我调用了BatchRemoveCart productidlist
BatchRemoveCart 又调用removecartitem(key)来进行移除操作
但问题就出在这,通过输出,我发现,在实际移除时,发现两个怪事:
1,无规律的某些项目没法移出,不会产生任何错误
2,removecartitem中,判断了项目是否存在,如果存在,则移除,并且,输出判断表达式的值,但我发现,每次VBS判断的isexists的值是false,但它却莫名其妙的执行了remove操作.实在令人费解

转载于:https://www.cnblogs.com/Heroman/archive/2007/08/23/866674.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值