Click to See Complete Forum and Search --> : Remove element out of 2 dimensionale dynamicaly created array


flokke
02-05-2009, 11:33 AM
Hi

Been looking for a solution on this one for 3 days. Hope you boys (and girls) can help me out.

I have an array (allbikes(4,xx)) wich is filled from a database table.
One of the 'fields' is 'stock' which show the amount of the bikes in stock.

Next to each item, the user can click 'order' to order the selected bike.
'stock' goes to 'stock - 1' and the bike is put in a new array (orderbikes(3,xx)).

Next to the list where all bikes are shown I have a list with all ordered elements.

Next to the elements in de orderlist I have a wastebasket where items can be removed from the orderlist.

When I click the wastebasket stock is going to stock+1 for that specific element in the allbikes-list.

All goes well till here.

Problem is that I can't remove the item from the orderlist when I click the wastebasket.

eg.
one item in allbikes has stock = 3.
When i order that item stock goes to 2 in the allbikes list and the bike is added in the ordered list.
When I click the wastebasket in the orderlist next to that element, stock goes to 3 again in the allbikes list... but the element stays in the order list which mean that everytime I click the wastebasket it is going stock + 1 in the allbikes list...

So I need to 'delete' the item in orderlist (remove it from the orderbike array.

Hope anyone understands...

I tried different solutions from the net, but none worked for me.

Thx for all your help.


This is what i've written when a user clicks the wastebasket:

id2 = cInt(request.querystring("id"))
itemindex = request.querystring("idx")

For i = 0 to UBound(allbikes, 2)
if cInt(allbikes(0,i)) = id2 then

allbikes(4,i) = cInt(allbikes(4,i)) + 1

end if
Next

'-------- code above does stock = stock + 1 and works when code below isn't there-------------


delete orderbikes, itemindex

Sub delete(ByRef orderbikes, ByVal itemindex)
Dim i
Dim ub

ub = UBound(orderbikes, 2) - 1

For i = itemindex To ub
orderbikes(i) = orderbikes(i + 1)
Next

ReDim Preserve orderbikes(ub)

End Sub

session("ab") = allbikes
session("ob") = orderbikes

response.redirect ("stock.asp")

downtime
02-06-2009, 11:44 AM
First off, is this a display problem or a programming problem? When you're saying that the "item stays in the order list" is it staying in the array or is it simply staying in the user display? The reason I ask is that it might be something as simple as the browser caching something.

To make sure your browser isn't caching, add a querystring based on the current system time to your redirect statement:

response.redirect("stock.asp?date=" & now())

Since this querystring will always change, you're definately going to refresh the page each time it's called. If the problem goes away, it was a caching problem.