Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP Form Collection

ASP Form Collection


Request Object Reference Complete Request object reference manual


The Form collection is used to retrieve the values of form elements from a form that uses the POST method.

Syntax

Request.Form(element)[(index)|.Count]

Parameters Description
element Required. The name of the form element from which this collection retrieves values.
index Optional. Specifies one of the multiple values of a parameter. From 1 to Request.Form(parameter).Count.

Example

Example 1

You can iterate over all the values in a form request. Suppose a user fills in the form by specifying two values for the color element - Blue and Green - you can retrieve these values like this:

<% for i=1 to Request.Form("color").Count

  Response.Write(Request.Form("color")(i) & "
")

next

%>

Output:

Blue

Green

Example 2

Take a careful look at this form:

First name:

Last name:

Your favorite color:

Suppose the following request is sent:

firstname=John&lastname=Dove&color=Red

Now we can use the information from the form in 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 which elements to display:

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

then the output will look like this:

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


Request Object Reference Complete Request object reference manual