Chapter 1: ColdFusion Tags
</CFOUTPUT>
<P>If we would like more than one condition to be the case,
we can ask for a list of the centers in San Diego <B>OR</B>
Santa Ana.
can use CFELSE to show only the names and cities of the
other centers.
<P>Notice how a nested CFIF is used to specify
the location of the featured site (Santa Ana or San Diego).
<!--- use CFIF to specify a conditional choice for multiple
options; also note the nested CFIF --->
<hr>
<P>Complete information is shown for centers in San Diego
or Santa Ana.
<CFOUTPUT QUERY="getCenters">
<CFIF city is "San Diego" OR city is "Santa Ana">
<H4>Featured Center in <CFIF city is "San Diego">San
<B>Name/Address:</B>#Name#, #Address1#, #City#, #State#
<BR><B>Contact:</B> #Contact#<BR>
<CFELSE>
<BR><I>#Name#, #City#</I>
</CFIF>
</CFOUTPUT>
<P>Finally, we can use CFELSEIF to cycle through a number
of conditions and produce varying output.
can use CFCASE and CFSWITCH for a more elegant representation
of this behavior.
<hr>
<P>
<!--- use CFIF in conjunction with CFELSEIF to specify
more than one branch in a conditional situation --->
<CFOUTPUT QUERY="getCenters">
<CFIF city is "San Diego" OR city is "Santa Ana">
<BR><I>#Name#, #City#</I> (this one is in <CFIF city is "San
<CFELSEIF city is "San Francisco">
<BR><I>#Name#, #City#</I> (this one is in San Francisco)
<CFELSEIF city is "Suisun">
<BR><I>#Name#, #City#</I> (this one is in Suisun)
<CFELSE>
<BR><I>#Name#</I> <B>Not in a city we track</B>
</CFIF>
</CFOUTPUT>
</BODY>
</HTML>
If the center does not follow this condition, we
All other centers are listed in italics:
Diego<CFELSE>Santa Ana</CFIF></H4>
Diego">San Diego<CFELSE>Santa Ana</CFIF>)
Note that you
101
Need help?
Do you have a question about the COLDFUSION 4.5-CFML LANGUAGE and is the answer not in the manual?
Questions and answers