Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

ASP Form Collection


❮ Complete Request Object Reference

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]

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

Examples

Example 1

You can loop through all the values in a form request. If a user filled out a form by specifying two values - Blue and Green - for the color element, you could retrieve those values like this:

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

Output:

Blue
Green

Example 2

Consider the following 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:
<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>

The following request might be 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 any element to display, like this:

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

the output would look like this:

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

❮ Complete Request Object Reference
×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.