<cfcase>

Handle one case of a <cfswitch>

This tag must have a body.

This tag is also supported within <cfscript>

<cfcase value=string delimiters=string ><!--- body ---></cfcase>
Attribute Description
value
string, required

One or more constant values that cfswitch compares to the specified expression case-insensitive comparison.

If a value matches the expression, cfswitch executes the code between the cfcase start and end tags.

Separate multiple values with a comma or other delimiter, as specified in the delimiters parameter.

Duplicate value attributes are not allowed and causes a runtime error.

delimiters
string, optional

Specifies the character that separates multiple entries in a list of values.

Examples

<cfset expr = 2>
<cfswitch expression="#expr#">
    <cfcase value=1>
        this is from case 1
    </cfcase>
    <cfcase value=2$3$4 delimiters="$">
        this is from case 2
    </cfcase>
    <cfdefaultcase>
        this is from default part
    </cfdefaultcase>
</cfswitch>
<cfscript>
    switch(1){
        case 1:
            result = 1;
            break;
        case 0:
            result = 0;
            break;
        default:
            result = "defaultCase";
    }
    dump( result );
</cfscript>

See also