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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting displayed form variables

Status
Not open for further replies.

benniesanders

Programmer
Jan 20, 2002
199
US
Greetings, I'm building a lengthy contact form and when I test it, I'm using the following code:
Code:
	  	For Each sItem In Request.Form
		Response.Write(sItem)
		Response.Write "=" &  request.form(sItem) & "<br>"
  		Next
Is there some way to display these in in the same order they are in the form? Right now, the results are all over the place... Thanks!
 
If the response comes from a select statement, add ORDER BY clause. For instance, if you have ORDER BY 2, it will sort the second column.
 
The short answer is "sometimes". According to the actual specification there is no requirement that items be passed in the same order that they appeared in. Add to that the fact that the order items appear is not defined (ie, items can appear in one order in the HTML and another order in the actual browser) and basically you get an answer that add's up to "Sometimes".

In reality I would caution you to never depend on the order of the items. While in many, many cases the order will stay the same each time you post a page, the fact that there is no requirement for it to stay the same leaves us open to future browsers trying to do thing in a more helpful manner (such as somneone deciding that alphabetical makes more sense).

 
Many thanks to both of you. I was just being lazy and thought it would be neat to take a shortcut, ha! Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top