![]() |
To create an action page for the form: |
<HTML> <HEAD> <TITLE>Retrieving Employee Data Based on Criteia from Form</TITLE> </HEAD> <BODY> <CFQUERY NAME="GetEmployees" DATASOURCE="CompanyInfo"> SELECT FirstName, LastName, Salary FROM Employees WHERE LastName='#Form.LastName#' </CFQUERY> <H4>Employee Data Based on Criteria from Form</H4> <CFOUTPUT query="GetEmployees"> #FirstName# #LastName# #Salary#<BR> </CFOUTPUT> </BODY> </HTML>
actionpage.cfm
within the myapps
directory.
formpage.cfm
in your browser.
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 | 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 |
When using form variables, keep the following guidelines in mind: