Form Variable Notes And Considerations - MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Develop Manual

Developing web applications with coldfusion
Table of Contents

Advertisement

36
5.
Enter data for the LastName form control and submit it.
6.
Return to the form in your browser.
7.
Reset the values.
8.
Do not check the checkbox and submit the form again.
An error occurs when the checkbox does not pass to the action page.
You will receive errors if you submit the form without checking the checkbox form
controls. You will learn how to apply conditional logic to your action page to
compensate for this HTML limitation in
page
Code Review
Code
<CFQUERY NAME="GetEmployees"
DATASOURCE="CompanyInfo">
SELECT FirstName, LastName, Salary
FROM Employees
WHERE LastName='#Form.LastName#'
<CFOUTPUT query="GetEmployees">
#FirstName#
#LastName#
#Salary#<BR>
</CFOUTPUT>

Form Variable Notes and Considerations

When using form variables, keep the following guidelines in mind:
A form variable's scope is the action page.
Prefix form variables with "form." when referencing them on the action page.
Surround variable values with pound signs (#) for output.
Checkboxes and radio buttons are only passed to the action page if an option is
selected.
51.
Developing Web Applications with ColdFusion
"Testing for a variable's existence" on
Description
Query the datasource CompanyInfo and name
the query GetEmployees.
Retrieve the FirstName, LastName, and Salary
fields from the Employees table, but only if the
value of the LastName field matches what the
user entered in the LastName text box in the
form on
.
formpage.cfm
Display results of the GetEmployees query.
Display the value of the FirstName, LastName,
and Salary fields for a record, starting with the
first record, then go to the next line. Keep
displaying the records that match the criteria
you specified in the SELECT statement,
followed by a line break, until you run out of
records
Close the CFOUTPUT block

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 4.5

Table of Contents