Wrox Programmer Forums
|
ASP E-commerce As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP E-commerce section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 6th, 2005, 05:17 PM
Registered User
 
Join Date: Jun 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to seanklosky
Default 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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating input values with arrays Ray Z Javascript 0 July 19th, 2006 09:20 PM
Chapter 2: Adding Arrays Invincible Pear BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 4 January 2nd, 2006 07:25 AM
Multidemmesional Arrays OR arrays gmoney060 Classic ASP Basics 3 November 1st, 2004 03:42 PM
Adding multiple form field values to database cdenequolo Classic ASP Basics 1 August 17th, 2004 05:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.