How do I (or can I) set the read order of a For Each Loop? Although the form is in the logical order I need, the loop is reading in an order other than what I want. Is there an attribute that I can put in the form fields to set precedence or is there another option?
My try at the unclear question:
The form has a collection. You can iterate through it. Typically one calls and reads each item as YOU see fit, not in the order of the form or iteration. ie
if request.form("my_element" = on then
doSomething
end if
I have built a CDONTS mailto form in HTML that posts to an ASP page. When the fields are posted I grab them in ASP (using the For Each loop) they are not displaying in the order I need them. Lets say I have a form that the user fills out and it looks like:
Small T-Shirt Quantity: [quantity goes here]
Large Sweatshirt Quantity: [quantity goes here]
Medium Golf Shirt Quantity: [quantity goes here]
Baseball Cap Quantity: [quantity goes here]
Additional Comments: [additional comments go here]
As you can see the form has been set up in a top to bottom fashion with fields in a certain order but the FOR EACH loop on the ASP page grabs the fields in whatever order it wants.
This is a sample of what the output may look like:
Ordered by: Sam Steller
Office: Sydney
Small T-Shirt Quantity: 10
Ship Attention to: Dave Peters
Large Sweatshirt Quantity: 5
Additional Comments: This is for our year end golf tournament, the last week of July. Please do not send until the second week of July
Medium Golf Shirt Quantity: 2
Baseball Cap Quantity: 8
The proper order should be:
Ordered by: Sam Steller
Office: Sydney
Ship Attention to: Dave Peters
Small T-Shirt Quantity: 10
Large Sweatshirt Quantity: 5
Medium Golf Shirt Quantity: 2
Baseball Cap Quantity: 8
Additional Comments: This is for our year end golf tournament, the last week of July. Please do not send until the second week of July
As you can see the FOR EACH loop is reading in a weird order. Can I set the read order of a For Each Loop to read top to bottom instead of the random order it is reading in now?
I hope that clears up any confusion and thanks for any help,
So you're trying to make a universal form mail handler, or something similar? I'm assuming that's why you're using the request.form.index vice the request.form.key?
Yeah, I was looking for a quick and dirty way of showing all the fileds in the form. I know I could do them each individually but because of the amount of fields I wanted to use the FOR EACH loop.
At the moment, I am using "For Each item in Request.Form". Below is some code:
For Each item in request.form
EmailBodyText = BodyText + Item & ": "
EmailBodyText = BodyText + Request.form(item)&vbCrlf
Next
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.