36
Developing Web Applications with ColdFusion
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
“Testing for a variable's existence” on
page 51
.
Code Review
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.
Code
Description
<CFQUERY NAME="GetEmployees"
DATASOURCE="CompanyInfo">
Query the datasource CompanyInfo and name
the query GetEmployees.
SELECT FirstName, LastName, Salary
FROM Employees
WHERE LastName=’#Form.LastName#’
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
.
<CFOUTPUT query="GetEmployees">
Display results of the GetEmployees query.
#FirstName#
#LastName#
#Salary#<BR>
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
</CFOUTPUT>
Close the CFOUTPUT block
Summary of Contents for COLDFUSION 4.5-DEVELOPING WEB
Page 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Page 14: ...xiv Developing Web Applications with ColdFusion...
Page 26: ...xxvi Developing Web Applications with ColdFusion...
Page 34: ...8 Developing Web Applications with ColdFusion...
Page 70: ...44 Developing Web Applications with ColdFusion...
Page 84: ...58 Developing Web Applications with ColdFusion...
Page 114: ...88 Developing Web Applications with ColdFusion...
Page 148: ...122 Developing Web Applications with ColdFusion...
Page 174: ...148 Developing Web Applications with ColdFusion...
Page 208: ...182 Developing Web Applications with ColdFusion...
Page 244: ...218 Developing Web Applications with ColdFusion...
Page 274: ...248 Developing Web Applications with ColdFusion...
Page 288: ...262 Developing Web Applications with ColdFusion...
Page 300: ...274 Developing Web Applications with ColdFusion...
Page 350: ...324 Developing Web Applications with ColdFusion...
Page 362: ...336 Developing Web Applications with ColdFusion...