Computers & ProgrammingASPBackend Development

ASP Form Collection

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.




variableSpecifies the name of the form element to retrieve values from.
indexSpecifies one of the multiple values for a variable, or index of the parameters in the form.
countSpecifies the number of multiple values for a form element.


Consider the following HTML page which contains a form to collect data.

<!DOCTYPE html>
    <title>My Page</title>
    <form action="results.asp" method="post">
        <p>First name: <input name="firstName"></p>
        <p>Pick one or more colors:</p>
        <select name="color" multiple="multiple">
        <p><input type="submit"></p>

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) & "<br />")

The results may look like this:

firstName = John
color = Red, Blue

Here are some additional examples, and the associated result.

Request.Form(2)Red, Blue
Request.Form("color")Red, Blue

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.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top