cfdefaultcase

Used only inside the cfswitch tag body. Contains code to
execute when the expression specified in the cfswitch tag does
not match any of the values specified by preceding cfcase tags.

  <cfdefaultcase>

 cfdefaultcase();

Examples
Sample code using the cfdefaultcase tag

vegetable = "";
switch(vegetable) {
    case "carrot":
        writeOutput("Carrots are orange.");
        break;
    default:
        writeOutput("You don't have any vegetables!");
        break;
}

Expected Result: You don't have any vegetables!

<cfset vegetable = "" />
<cfswitch expression="#vegetable#">
    <cfcase value="carrot">
        Carrots are orange.
    </cfcase>
    <cfdefaultcase>
        You don't have any vegetables!
    </cfdefaultcase>
</cfswitch>

Expected Result: You don't have any vegetables!

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub