Example 1
To loop through all the n variable values in a Query String:
The following request is sent:
http://www.w3schools.com/test/names.asp?n=John&n=Susan
and names.asp contains the following script:
<%
for i=1 to Request.QueryString("n").Count
Response.Write(Request.QueryString("n")(i) & "<br />")
next
%>
The file names.asp would display the following:
John
Susan
Example 2
The following string might be sent:
http://www.w3schools.com/test/names.asp?name=John&age=30
this results in the following QUERY_STRING value:
name=John&age=30
Now we can use the information in a script:
Hi, <%=Request.QueryString("name")%>.
Your age is <%= Request.QueryString("age")%>.
Output:
Hi, John. Your age is 30.
If you do not specify any variable values to display, like this:
Query string is: <%=Request.QueryString%>
the output would look like this:
Query string is: name=John&age=30
|