Can I use another cfswitch statement within the same cfswitch case?
<CFSWITCH EXPRESSION="nameOfPg">
<CFCASE VALUE="ClassMenu" >
<!---do something--->
</CFCASE>
<CFCASE VALUE="ReportsMenu">
<CFSWITCH EXPRESSION="#nameOfPg#">
<CFCASE VALUE="StudentMenu">
<!---do something--->
</CFCASE>
<CFCASE VALUE="DetailsMenu">
<!---do something--->
</CFCASE>
</CFSWITCH>
</CFCASE>
<CFDEFAULTCASE>
<!---do something--->
</CFDEFAULTCASE>
</CFSWITCH>
Yes, you can. The
EXPRESSIONattribute can be dynamic (e.g. a variable such asnameOfPg), but pay attention to the hashes#.nameOfPg(your top CFSWITCH) evaluates the string, not the actual value of the variablenameOfPg. To resolve a variable in an attribute, you need to use hashes#like you did in your inner CFSWITCH:#nameOfPg#.Fix your code:
and you should be good.
On a side note:
CFCASEon the other hand does not allow the use of dynamic values (due to to the way a switch works in Java/ColdFusion). You always have to use a static value here like you do right now. Just keep that in mind.