ASP Form Collection

Request Object Reference Manual

The Form collection is used to retrieve the values of form elements from forms using the POST method.

Note:If you need to post a large amount of data (more than 100kb), you cannot use Request.Form.

Syntax

Request.Form(element)[(index)|.Count]
Parameter Description
element Required. The name of the form element, from which the values are retrieved.
index Optional. Specifies one of the multiple values of a parameter. From 1 to Request.Form(parameter).Count.

Instance

Example 1

You can iterate through all the values in the form request. Suppose the user has filled out the form with two specified values - blue and green - you can retrieve these values like this:

<%
for i=1 to Request.Form("color").Count
Response.Write(Request.Form("color")(i) & "<br />")
next
%>

Output:

Blue
Green

Example 2

Please take a close look at this form:

<form action="submit.asp" method="post">
<p>First name: <input name="firstname"></p>
<p>Last name: <input name="lastname"></p>
<p>Your favorite color:</p>
<select name="color">
<option>Blue</option>
<option>Green</option>
<option>Red</option>
<option>Yellow</option>
<option>Pink</option>
</select>
</p>
<p><input type="submit"></p>
</form>

Suppose, the following request was sent:

firstname=John&lastname=Dove&color=Red

Now, we can use the information from the form with a script:

Hi, <%=Request.Form("firstname")%>. 
Your favorite color is <%=Request.Form("color")%>.

Output:

Hi, John. Your favorite color is Red.

If you do not specify the elements to be displayed:

Form data is: <%=Request.Form%> 

The output will be like this:

Form data is: firstname=John&lastname=Dove&color=Red

Request Object Reference Manual