ALP Request.Form collection
Contains the parameters sent through the HTTP POST method. This is usually a result of a form post. Values of the fields of the form are encoded by the browser - by default it uses URL encoding and their format is similar to the query string.

Form fields has names and textual values. The ASP module collects and serves them to the scripts through this collection.

Syntax:

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

Parameters:

variable - can be string or numeric 1-based index of the form field name

index - is a 1-based index of the value for the specified field name

All parameters are optional thus you can use Request.Form in the script and it will return a string containing raw content of the form. Omitting the index parameter will return the first value for the given form field specified by the variable. If a particular parameter does not exists empty string is returned. Form fields are recognized by name thus you can think that even if the form fields have different types they are equal for your application if their names are equal. Values of the all fields with the same name (specified by the variable parameter) are collected in its sub-collection.

Examples:

Following example lines will use this sample Form:

<FORM METHOD=POST ACTION="my.asp">
  <INPUT TYPE=TEXT NAME=a VALUE="v1">
  <SELECT NAME=b>
    <OPTION VALUE="v2a">First</OPTION>
    <OPTION VALUE="v2" SELECTED>Second - selected</OPTION>
    <OPTION VALUE="v2b">Third</OPTION>
  </SELECT>
  <INPUT TYPE=CHECKBOX NAME=c VALUE="v3" CHECKED>
  <INPUT TYPE=RADIO NAME=a VALUE="v4">
  <INPUT TYPE=RADIO NAME=a VALUE="v5" CHECKED>
  <INPUT TYPE=RADIO NAME=a VALUE="v6">
</FORM>

Suppose that the form is submitted with the default values used in the source above.

JScript/VBScript:

<%= Request.Form("a") %>

Will return v1

<%= Request.Form("c") %>

Will return v3

<%= Request.Form("b").Count %>

Will return 1

<%= Request.Form("a") %>

Will return 2

<%= Request.Form("a")(2) %>

Will return v5

<%= Request.Form("d") %>

Will return empty string

Collections can be also enumerated:

VBScript:

<%
  For Each item In Request.Form("a")
    Response.Write item & "<BR>"
  Next
%>

This will produce:
v1
v5

Remarks:

Form collection is implemented using the newObjects Collections components see Request collections comments for more information.

Applies to: Request object

See also: notes about the Request collections

 

newObjects Copyright 2001-2006 newObjects [ ]