Help Please

# Thread: Help Please

1. Senior Member
Join Date
Dec 1969
Posts
155

## Help Please

I am placing items into an array for a shopping cart. When I try to delete an item it is only deleting the very first item in the array and not the item i am selecting. Here is my code:<BR><BR>Private Sub DelItem()<BR> Dim arDel, DelNum<BR> Redim arDel(6, 0) <BR> Delnum = -1<BR> PartNum = arCart(0, 0)<BR> If UBound(arCart, 2) = 0 Then<BR> Redim arCart(6, 0)<BR> arCart(0, 0) = ""<BR> Session("arCart") = arCart<BR> Exit Sub<BR> End If<BR> For i = 0 to UBound(arCart, 2)<BR> If arCart(0, i) = PartNum Then<BR> DelNum = i<BR> Exit For<BR> End If<BR> Next<BR> If DelNum &#062; -1 Then<BR> For i = 0 to UBound(arCart, 2)<BR> If i &#060;&#062; DelNum Then<BR> If Not IsNull(arDel(0, 0)) And arDel(0, 0) &#060;&#062; "" Then<BR> Redim Preserve arDel(6, UBound(arDel, 2) +1)<BR> End If<BR> arDel(0, UBound(arDel, 2)) = arCart(0, i)<BR> arDel(1, UBound(arDel, 2)) = arCart(1, i)<BR> arDel(2, UBound(arDel, 2)) = arCart(2, i)<BR> arDel(3, UBound(arDel, 2)) = arCart(3, i)<BR> arDel(4, UBound(arDel, 2)) = arCart(4, i)<BR> arDel(5, UBound(arDel, 2)) = arCart(5, i)<BR> End If<BR> Next<BR> arCart = arDel<BR> Session("arCart") = arCart<BR> End If<BR>End Sub<BR><BR>at the button i am using javascript to capture the product# and a trigger then putting that # and trigger into a hidden form object. Then I say:<BR><BR>If Request.Form("Mode") = "Delete" Then<BR> DelItem<BR>End If<BR><BR>Can someone help me as to why it is deleting the first array object istead of the one i select?<BR><BR>Thanks!

2. Senior Member
Join Date
Dec 1969
Posts
5,104

## RE: Help Please

Your 5th line of code sets PartNum to be equal to the first array location.<BR><BR>You aren&#039;t actually getting that value from anywhere.<BR><BR>How do you expect it to know what to delete? Osmosis?<BR><BR>-Doug

3. Senior Member
Join Date
Dec 1969
Posts
155

## RE: Help Please

Thanks, Your right after just 1 more minute of going over it, it hit me. duh!<BR><BR>Thanks anyway!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•