Open In App

ASP Request.Form Collection

Last Updated : 03 Feb, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

The Request.Form Collection in ASP is used for returning the collection of form elements that posted to the HTTP request body, with a form using the POST method. 

Syntax

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

Parameter:

  • Element: It specifies the name of the form elements. It is a required attribute.
  • Index: It is an optional parameter that represents a position of form elements that used to access. It can be any integer from 1 to n.

Example 1: Below code uses the for loop to access the form values filled by the user. We could retrieve those values like this: 

PHP




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


Output: 

Blue
Green

Example 2: 

HTML




<form action="submit.asp" method="post">
    <p>First name: <input name="firstname"></p>
    <p>Last name: <input name="lastname"></p>
  
    Your favorite game:
    <select name="game">
    <option>Hockey</option>
    <option>Cricket</option>
    <option>FootBall</option>
    <option>Golf</option>
    <option>Basket Ball</option>
</select>
  
<p><input type="submit"></p>
</form>


Following Values filled by the user:

firstname=naman&lastname=jain&game=cricket

Here is the ASP code that is used to retrieve the information from the form. 

PHP




Hello <%=Request.Form("firstname")%>.  
Your favorite game is <%=Request.Form("game")%>.


Output

Hi, Naman. Your favorite game is Cricket


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads