> If I just try to do the ArrayDeleteAt(Session.UserCart, 3)
> within an ArrayLength of 4 I get the following message:
>
> The element at Position 1, of Dimension 2, of an array object
> used as part of an _expression_, cannot be found.
>
> Before I tried to delete one of the items from the cart, I
> had the following in the Array:
>
> Element 1 has the Array Header Info which has 7 child
> elements in it which are ProductID, ProductName,
> ProductOptionID, ProductOptionName, ProductQuantity,
> ProductOptionPrice, ProductPrice
>
> Element2 has 1, USA Flag Shirt, 0, 0, 1, 0, 0.01
> Element3 has 2, 8" Round Wall Clock, 1, w/ Chapter Patch, 2, 0, 19.95
> Element4 has 3, 10" Round Wall Clock, 0, 0, 3, 0, 16.95
>
> And when I delete Element 3 which was placed in the Cart by
> accident, the cfdump shows that element4 has moved up to
> element3 and then shows element4 as being empty which
> produces the above error message.

When you delete something from an array, the array is compressed. This is
the correct behavior. I'm not sure why you have metadata in the first
element; instead, if you want to track values by name you should use an
array of structures:

<cfset Session.UserCart = ArrayNew(1)>
<cfset Session.UserCart[1] = StructNew()>
<cfset Session.UserCart[1].ProductID = 1>
...

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
phone: 202-797-5496
fax: 202-797-5444
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to