Chapter 5: Making Variables Dynamic
CFML Code
<CFIF #Form.LastName# is not "">
AND Employees.LastName LIKE
'#form.LastName#%'
</CFIF>
<CFIF #Form.Salary# is not "">
AND Employees.Salary >=
#form.Salary#
</CFIF>
<CFIF isDefined("Form.Contract") IS
"YES">
AND Employees.Contract = 'Yes'
<CFELSE>
AND Employees.Contract = 'No'
</CFIF>
Description
If the user entered anything in the
LastName text box in the form, add "AND
Employees.LastName LIKE '[what the user
entered in the LastName text box]%'" to the
SQL statement.
If the user entered anything in the Salary
text box in the form, add "AND
Employees.Salary >= [what the user
entered in the Salary text box]" to the SQL
statement.
If the user checked the Contractor check
box, get data for the employees who are
contractors, otherwise, get data for
employees who are not contractors.
57
Need help?
Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?