User Guide

Chapter 5: Making Variables Dynamic 57
<CFIF #Form.LastName# is not "">
AND Employees.LastName LIKE
’#form.LastName#%’
</CFIF>
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.
<CFIF #Form.Salary# is not "">
AND Employees.Salary >=
#form.Salary#
</CFIF>
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.
<CFIF isDefined("Form.Contract") IS
"YES">
AND Employees.Contract = ’Yes’
<CFELSE>
AND Employees.Contract = ’No’
</CFIF>
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.
CFML Code Description