User Guide

Table Of Contents
Working with action pages 613
Forms guidelines
When using forms, keep the following guidelines in mind:
To make the coding process easy to follow, name form controls the same as target database
fields. For example, if a text control corresponds to a data source FirstName field, use
FirstName as the control name.
For ease of use, limit radio buttons to between three and five mutually exclusive options. If you
need more options, consider a drop-down list.
Use list boxes to allow the user to choose from many options or to choose multiple items from
a list.
Check boxes, radio buttons, and list boxes do not pass data to action pages unless they are
selected on a form. If you try to reference these variables on the action page, you receive an
error if they are not present. For information on how to determine whether a variable exists on
the action page, see Testing for a variable’s existence” on page 616.
You can dynamically populate drop-down lists using query data. For more information, see
“Dynamically populating list boxes” on page 625.
Working with action pages
When the user submits a form, ColdFusion runs the action page specified by the cfform or form
tag
action attribute. A ColdFusion action page is like any other application page, except that you
can use the form variables that are passed to it from an associated form. The following sections
describe how to create effective action pages.
Processing form variables on action pages
The action page gets a form variable for every form control that contains a value when the form is
submitted.
Note: If multiple controls have the same name, one form variable is passed to the action page with a
comma-delimited list of values.
A form variables name is the name that you assigned to the form control on the form page. Refer
to the form variable by name within tags, functions, and other expressions on an action page.
On the action page, the form variables are in the Form scope, so you should prefix them with
“Form.” to explicitly tell ColdFusion that you are referring to a form variable. For example, the
following code references the LastName form variable for output on an action page:
<cfoutput>
#Form.LastName#
</cfoutput>
The Form scope also contains a list variable called Form.fieldnames. It contains a list of all form
variables submitted to the action page. If no form variables are passed to the action page,
ColdFusion does not create the
Form.fieldnames list.