Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling All ASP Forum Experts (For Each loop read order)

Status
Not open for further replies.

balance

Programmer
Feb 5, 2002
52
0
0
CA
Hello,

Does any one have an answer for this thread?

thread333-292741

Thanks,

AJ
 
Dun really understand the question, maybe you can explain more clearly? ------------------
Freedom is a Right
 
Your question is not clear:

Your Question

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

and so on. Jonathan Galpin
 
Sorry about any confusion,

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:

Ordered by: [name goes here]
Office: [office goes here]
Ship Attention to: [name goes here]

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,

AJ

 
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?
 
Travmak,

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


AJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top