I have an order form that is builds a table from a database. It displays a
product, an input box for quantity ordered and an option box(finish). The options
are the same for each line built, and are hard-coded.
Product Quantity Finish
1" nails | | Plain
Brass
Galvanized

2" nails | | Plain
Brass
Galvanized

3" nails | | Plain
Brass
Galvanized

When the form is submitted, product and quantity ordered come to the asp action
page as (in this example) a 3 element array of request.form, but the options are
an array, whose number of elements is the number of them selected.

For instance if the user orders 20 1" nails Plain and 50 3" nails Brass
it looks like this on the action page:

request.form("Product")(1)="1_nails"
request.form("Product")(2)=""
request.form("Product")(3)="3_nails"

request.form("Quantity")(1)="20"
request.form("Quantity")(2)=""
request.form("Quantity")(3)="50"

request.form("Finish")(1)="Plain"
request.form("Finish")(2)="Brass"

On the action page, I loop request.form("Quantity").count times looking for a
quantity not equal to "" to build the SQL to update a database, but there are only
2 finish items, so the index for the third item is not 3 but 2.
How can I sync this?
Thanks,
MikeR

Re: Form to action page by Stefan

Stefan
Fri Jun 03 04:05:33 CDT 2005

Why are you building an array?
(especially for data that does not conform to an array structure)

If you really need an array for some reason, the array should be for each row (not each column) where each form field name in a row
is numbered as FieldName# (and you are rediming the array between each row in your loop)
to get row 1
ItemArray(1,1) = request.form("Product1")
ItemArray(1,2) = request.form("Quantity1")
ItemArray(1,3) = request.form("Finish1")
to get row 2
ItemArray(2,1) = request.form("Product2")
ItemArray(2,2) = request.form("Quantity2")
ItemArray(2,3) = request.form("Finish2")
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.net-sites.com/sitebuilder/newsgroups.asp
_____________________________________________


"MikeR" <nf4l@pobox.com> wrote in message news:OAJ%23pS5ZFHA.1148@tk2msftngp13.phx.gbl...
|I have an order form that is builds a table from a database. It displays a
| product, an input box for quantity ordered and an option box(finish). The options
| are the same for each line built, and are hard-coded.
| Product Quantity Finish
| 1" nails | | Plain
| Brass
| Galvanized
|
| 2" nails | | Plain
| Brass
| Galvanized
|
| 3" nails | | Plain
| Brass
| Galvanized
|
| When the form is submitted, product and quantity ordered come to the asp action
| page as (in this example) a 3 element array of request.form, but the options are
| an array, whose number of elements is the number of them selected.
|
| For instance if the user orders 20 1" nails Plain and 50 3" nails Brass
| it looks like this on the action page:
|
| request.form("Product")(1)="1_nails"
| request.form("Product")(2)=""
| request.form("Product")(3)="3_nails"
|
| request.form("Quantity")(1)="20"
| request.form("Quantity")(2)=""
| request.form("Quantity")(3)="50"
|
| request.form("Finish")(1)="Plain"
| request.form("Finish")(2)="Brass"
|
| On the action page, I loop request.form("Quantity").count times looking for a
| quantity not equal to "" to build the SQL to update a database, but there are only
| 2 finish items, so the index for the third item is not 3 but 2.
| How can I sync this?
| Thanks,
| MikeR



Re: Form to action page by MikeR

MikeR
Fri Jun 03 09:27:43 CDT 2005

Hi Stefan -
I'm not building an array. I'm accessing one (the request.form variables are an array).
The problem is that the number of items in the array is not the same for all the
variables. If I have 3 products, and a person orders the first and last, the quantity
comes into the action page as a 3 element array with the center element = "". Finish comes
in as a 2 element array. So a For Next loop that runs request.form("Quantity").count
times, and uses X as the loop counter, runs out of indexes.
I also can't use different variable names (Product1, Product2) because the HTML is created
dynamically on the form page.

If I could build the array as you depict, that would probably aid in a solution.
MikeR

Stefan B Rusynko wrote:
> Why are you building an array?
> (especially for data that does not conform to an array structure)
>
> If you really need an array for some reason, the array should be for each row (not each column) where each form field name in a row
> is numbered as FieldName# (and you are rediming the array between each row in your loop)
> to get row 1
> ItemArray(1,1) = request.form("Product1")
> ItemArray(1,2) = request.form("Quantity1")
> ItemArray(1,3) = request.form("Finish1")
> to get row 2
> ItemArray(2,1) = request.form("Product2")
> ItemArray(2,2) = request.form("Quantity2")
> ItemArray(2,3) = request.form("Finish2")