Form to action page

M

MikeR

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
 
S

Stefan B Rusynko

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")



|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
 
M

MikeR

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top