Name
cfswitch
Synopsis
<cfswitch expression="expression">
<cfcase value="value" delimiters="delimiter">
HTML and CFML
</cfcase>
<cfcase value="value" delimiters="delimiter">
HTML and CFML
</cfcase>
...
[<cfdefaultcase>
HTML and CFML
</cfdefaultcase>]
</cfswitch>Evaluates an expression against multiple values until a match is
made. Once a match has been made, cfswitch passes
control to the appropriate cfcase tag where
additional action can take place. If no value
matches expression, the code between the
cfdefaultcase tags is executed. As of ColdFusion
MX, the cfdefaultcase tag no longer has to be
coded as the last statement in a cfswitch block,
although it is considered good style to do so.
cfswitch/cfcase/cfdefaultcase
is similar in function to
cfif/cfelseif/cfelse.
cfswitch/cfcase/cfdefaultcase
is usually faster than using multiple cfif
statements and is generally easier to read.
Attributes
-
expression="expression" Any ColdFusion expression that evaluates to a simple value (string, number, Boolean, date/time). Required.
-
value="value" A value or delimited list of values
cfswitchuses to perform a case-insensitive comparison against the specifiedexpression. If a value listed invaluematchesexpression, the code between thecfcasetags is executed. Required.-
delimiters="delimiter" Specifies the character that separates multiple entries in the
valueattribute. Optional. The default is a comma.