Sun
ONE Active Server Pages Product Home Page Developer Site Version
 

ContentsPreviousNextIndex



Examples: ASP Request Object QueryString Collection

An iterator can be used to loop through all data values in a query string. For example, if the following request is sent:

http://NAMES.ASP?Q=Fred&Q=Sally 

and NAMES.ASP contained the following script:

For Each item In Request.QueryString("Q") 
   Response.Write item & "<BR>" 
Next

NAMES.ASP would display the following:

Fred 
Sally

Instead of using For Each, you can loop through data values in a query string using the Count variable:

For I = 1 To Request.QueryString("Q").Count 
Response.Write Request.QueryString("Q")(I) & "<BR>" 
Next

The following client request:

/scripts/directory-lookup.asp?name=fred&age=22

results in the QUERY_STRING value:

name=fred&age=22. 

The QueryString collection would then contain two members, name and age.

Welcome, <%= Request.QueryString("name") %>. 
Your age is <%= Request.QueryString("age") %>.

This script displays:

"Welcome, Fred. Your age is 22."


ContentsPreviousNextIndex