How to add multiple switch cases in coldfusion tag and script ?
<!--- Tag Syntax --->
<cfset Fruit = "Apple">
<cfswitch expression="#Fruit#">
<cfcase value="Mango,Apple,Watermelon">
I love Mango and Apple and Watermelon.
</cfcase>
<cfcase value="Guava">
I like Guava.
</cfcase>
<cfdefaultcase>
I don't like fruit
</cfdefaultcase>
</cfswitch>
Output: I love Mango and Apple and Watermelon.
<!--- Script Syntax --->
<cfscript>
Fruit = "Apple";
switch( Fruit ) {
case "Mango": case "Apple": case "Watermelon":
writeOutput("I love Mango and Apple and Watermelon.");
break;
case "Guava":
writeOutput("I like Guava.");
break;
default:
writeOutput("I don't like fruit");
break;
}
</cfscript>
Output: I love Mango and Apple and Watermelon.