Connecting Tech Pros Worldwide Help | Site Map

Basic array help!

Newbie
 
Join Date: Jun 2007
Posts: 2
#1: Jun 20 '07
Hi guys,

I'm new to ASP and need some array help.

I need to have a shopping cart. When you visit the site it creates a session and an array. When you click add to basket it adds the item ID to the array.

I can't get my head around how i allocate it an array slot and then empty out the array in the checkout. I presume i'd need a loop or something to go through each array item and print it out.

Thanks in advance,

Dave
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#2: Jun 20 '07

re: Basic array help!


Quote:

Originally Posted by comedydave

Hi guys,

I'm new to ASP and need some array help.

I need to have a shopping cart. When you visit the site it creates a session and an array. When you click add to basket it adds the item ID to the array.

I can't get my head around how i allocate it an array slot and then empty out the array in the checkout. I presume i'd need a loop or something to go through each array item and print it out.

Thanks in advance,

Dave

I'm not sure you can do an array in session variables. I would put one long string like this:
Expand|Select|Wrap|Line Numbers
  1. session("cart") = "playdough, fakeMoney, turtleFood"
  2. session("cartQuant") = "1, 3, 2"
  3. session("cartPrice") = "3.14, 2.79, 1.99"
  4.  
then to access them I would create arrays using the split function:
Expand|Select|Wrap|Line Numbers
  1. dim carts, cartQuants, cartPrices
  2. carts = split(session("cart"), ", ")
  3. 'and so on
does this make sense?

Jared
Reply


Similar ASP / Active Server Pages bytes