User Guide

Table Of Contents
Working with queries and data 617
In either of these examples, if the user leaves the FirstName field empty, ColdFusion rejects the
form submittal and returns a message informing the user that the field is required. You can
customize the contents of this error message.
If you use a
required attribute, you customize the message by using the message attribute, as
follows:
<cfinput type="Text" name="FirstName" size="20" maxlength="35" required="Yes"
message="You must enter your first name.">
If you use a hidden field tag, you customize the message using the value attribute of the hidden
field, as follows:
<input type="hidden" name="FirstName_required"
value="You must enter your first name.">
Form variable notes and considerations
When using form variables in an action page, keep the following guidelines in mind:
A form variable is available on the action page and pages that it includes.
Prefix form variables with "Form." when referencing them on the action page.
Surround variable values with number signs (#) for output.
Variables for check boxes, radio buttons, and list boxes with size attributes greater than 1 only
get passed to the action page if you select an option. Text boxes, passwords, and textarea fields
pass an empty string if you do not enter text.
An error occurs if the action page tries to use a variable that was not passed.
If multiple controls have the same name, one form variable is passed to the action page with a
comma-delimited list of values.
You can validate form variable values on the client or the server.
Working with queries and data
The ability to generate and display query data is one of the most important and flexible features
of ColdFusion. The following sections describe more about using queries and displaying their
results. Some of these tools are effective for presenting any data, not just query results.
Using HTML tables to display query results
You can use HTML tables to specify how the results of a query appear on a page. To do so, you
put the
cfoutput tag inside the table tags. You can also use the HTML th tag to put column
labels in a header row. To create a row in the table for each row in the query results, put the
tr
block inside the
cfoutput tag.
In addition, you can use CFML functions to format individual pieces of data, such as dates and
numeric values.