Skip to Main Content
Programming ColdFusion MX, 2nd Edition
book

Programming ColdFusion MX, 2nd Edition

by Rob Brooks-Bilson
August 2003
Intermediate to advanced content levelIntermediate to advanced
1140 pages
68h 45m
English
O'Reilly Media, Inc.
Content preview from Programming ColdFusion MX, 2nd Edition

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 cfswitch uses to perform a case-insensitive comparison against the specified expression. If a value listed in value matches expression, the code between the cfcase tags is executed. Required.

delimiters=" delimiter "

Specifies the character that separates multiple entries in the value attribute. Optional. The default is a comma.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming ColdFusion

Programming ColdFusion

Rob Brooks-Bilson

Publisher Resources

ISBN: 0596003803Supplemental ContentErrata Page