http://club.coolmaps.com
tomorrow's fusion today

Creating Conditional Code
The CFIF set of tags allow you to easily create conditional Cold Fusion code. The CFIF tag family is made up of <CFIF>CFELSEIF><CFELSE></CFIF>. Ignore the slashes, brackets and CF, and you'll notice the syntax is basic decision making stuff. If a condition is met, do this, if it isn't do something else.

Here's an example of a conditional process in plain english:

if the name of the person who submitted the form is Tarzan, say 'Hiya Big Fella!', else if the name of the person is Jane, say 'Me Tarzan!' else say 'This jungle isn't big enough for all of us!'

Using CFIF we could write:

<CFIF Name IS "Tarzan">
Hiya Big Fella!
<CFELSEIF Name IS "Jane">
Me Tarzan!
<CFELSE>
This jungle isn't big enough for both of us!
</CFIF>

Enough of the theory, let's use CFIF in practice. Select a name or leave it with no name selected, we'll use CFIF to handle the response.

There's nothing unusual in the source for this form. We've called the dropdown 'name'.

[ to top of page ]

to home page
CF Workshop intro CFERROR and application.cfm CFFORM - auto javascript validation CFPARAM - setting default values CFIF - required fields CFIF - creating conditional code

Support CCC thru Amazon. Buy CF Bible 2 - Advanced CF Application Development

 
member of club xChange
downloads contact us site map