Arrays: Adding values from multiple arrays
UPDATE:
I fixed this easily, I just added a variable that adds up each time the loop is executed. The added code is in red below
***************************
Hello,
I have a shopping cart that creates/passes three arrays for Adult Price, Child Price and Senior Price.
There is also three arrays that pass the quantity purchased for each price array above.
What I need to do is add up each Adult price * the quantity (an adult subtotal) for each reservation made.
I need to do this for all three, but I figure if anybody can solve for X I can figure out Y and Z.
Here's what I have so far:
*********************************
iqtyadult1 = Split(Request.Form("qtyadult1"), ",")
iqtychild1 = Split(Request.Form("qtychild1"), ",")
iqtystud1 = Split(Request.Form("qtystud1"), ",")
ipriceadult1= Split(request.form("priceadult1"), ",")
ipricechild1=Split(request.form("pricechild1"), ",")
ipricestud1= Split(request.form("pricestud1"), ",")
FOR i = LBound(iqtyadult1) TO UBound(iqtyadult1)
totalAdult = iqtyadult1(i) * ipriceadult1(i)
totalAdult1 = totalAdult1 + totalAdult
tqtyadult1 = totalAdult
NEXT
FOR e = LBound(iqtychild1) TO UBound(iqtychild1)
totalChild = iqtychild1(e) * ipricechild1(e)
totalChild1 = totalChild1 + totalChild
tqtychild1 = totalChild
NEXT
FOR s = LBound(iqtystud1) TO UBound(iqtystud1)
totalStudent = iqtystud1(s) * ipricestud1(s)
totalStudent1 = totalStudent1 + totalStudent
tqtystud1 = totalStudent
NEXT
*********************************
I know this works for simple value combinations, but it doesn't work if there is more than one item in the cart.
Thanks in advance!
Sean
|