Using forms in your ASP Applications is a common way of collecting user input for further processing. The ASP Form collection retrieves the values of form elements posted to the HTTP request body, using the POST method. Unlike variables that are passed in a query string using the GET method, form input is passed in the Request headers.
Syntax
Request.Form(element)[(index)|.Count]
Parameters
Examples
Consider the following HTML page which contains a form to collect data.
On the target page, results.asp, you can use the Request.Form Collection to collect the information passed in the Request headers.
In the following example, if you were interested in looping through all of the form elements and capturing the associated values, you can use this sample code:
<%
For x = 1 to Request.Form.Count
Response.Write(Request.Form.Key(x) & " = “)
Response.Write(Request.Form.Item(x) & “
”)
Next
%>
The results may look like this:
firstName = John color = Red, Blue
Here are some additional examples, and the associated result.
Once you understand how to access the variable or variables submitted using a form, the next step is to determine what to do with those values. You may use that information to look up product information stored in a database, or send an email message to a user.