Use decision functions to test for the presence of ColdFusion elements such as form variables, queries, and their simple values so that you can perform conditional processing.
When you use decision functions:
The table below describes the most frequently used decision functions.
Refer to the CFML Language Reference for ColdFusion Express for a complete listing.
Function | Usage |
---|---|
IsDefined | Tests if a variable by a specific name exists. |
IsDebugMode | Tests if debugging is enabled on the page. |
IsDate | Tests if a variable value is time-date. |
IsNumeric | Tests if a variable value is numeric. |
IsQuery | Tests if a variable contains query data. |
IsStruct | Tests if a variable contains structure data. |
Checkbox and radio button form variables only pass to action pages when an option is enabled on the form.
The code below is added to a form's action page to check for the existence of a checkbox variable.
<CFIF IsDefined("Form.Contract") IS "YES"> Status: Contract Employee <CFELSE> Status: Permanent Employee </CFIF>
During the next procedure, use this expression syntax on your action page to check for the existence of a checkbox before trying to process it.
![]() |
To test for a variable's existence: |
ActionPage.cfm
in HomeSite.Contract Status: #Form.Contract#<BR>
within the CFOUTPUT block.You will replace it with new code as you go.
<CFIF IsDefined("Form.Contract") IS "YES">
Status: Contract Employee
Status: Permanent Employee
<CFIF IsDefined("Form.Contract") IS "YES"> Status: Contract Employee <CFELSE> Status: Permanent Employee </CFIF>
FormPage.cfm
in a browser. ActionPage.cfm
should return all the values that you entered on the form.
The status field should appear as Contract Employee.
If you receive errors, read the error message and check for spelling mistakes on the action page.
The status field should appear as Pemanent Employee.
Click here to see what results you should get.
Click here to see the new code on the action page.
Move on in this chapter to learn how to use operators to perform conditional logic testing.