Used only inside the cfswitch tag body. Contains code to execute when the expression specified in the cfswitch tag does not match the value specified by a cfcase tag.


Flow-control tags



See also

cfcasecfswitchcfswitchcfcase, and cfdefaultcase in the Developing ColdFusion Applications


ColdFusion MX: Changed placement requirements: this tag does not have to follow all cfcase tags in the cfswitch tag body.


The contents of the cfdefaultcase tag body executes if the expression attribute of the cfswitch tag does not match any of the values specified by the cfcase tags in the cfswitch tag body. The contents of the cfdefaultcase tag body can include HTML and text, and CFML tags, functions, variables, and expressions.
You can specify only one cfdefaultcase tag within a cfswitch tag. You can put the cfdefaultcase tag at any position within a cfswitch statement; it is not required to be the last item, but it is good programming practice to put it last.


<!--- The following example displays a grade based on a 1-10 score.
Several of the cfcase tags match more than one score. 
For simplicity, the example sets the score to 7. ---> 
<cfset score="7"> 
<cfswitch expression="#score#"> 
<cfcase value="10"> 
<cfset grade="A"> 
<cfcase value="9;8" delimiters=";"> 
<cfset grade="B"> 
<cfcase value="7;6" delimiters=";"> 
<cfset grade="C"> 
<cfcase value="5;4;" delimiters=";"> 
<cfset grade="D"> 
<cfset grade="F"> 
Your grade is #grade# 

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy