[thelist] CFswitch doesn't.
Jeff Howden
jeff at jeffhowden.com
Fri Aug 12 18:00:35 CDT 2005
Frank,
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Frank
>
> The following code is a simple switch/case statement.
> Ideally, when the variable fuseaction EQ anything but
> "contact" or "about", nothing should no document should
> be included. In this case, both are included regardless
> of the value of the variable "fuseaction".
>
> Can anyone see what I might be missing?
>
> <!--- Include UDF's --->
> <cfinclude template="../udf/include.cfc">
> <cfinclude template="../udf/cfparam.cfc">
>
> <!--- Switch among various fuses --->
> <cfscript>
> cfparam ("fuseaction", "");
> switch(fuseaction) {
> case "about": {
> include("../pages/dsp_about.cfm");
> }
> case "contact": {
> include("../pages/dsp_contact.cfm");
> }
> default: {}
> break;
> }
> </cfscript>
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
The problem is caused by your (mis)understanding of the differences between
switches in a <cfscript> block and the <cfswitch> tag. Cases in a
<cfswitch> block have an implicit break, making them exclusive whereas cases
within a switch in a <cfscript> block must have an explicit break added.
So, to fix up your code block, you'd add a "break;" as the last line of each
of your case statements:
<!--- Include UDF's --->
<cfinclude template="../udf/include.cfc">
<cfinclude template="../udf/cfparam.cfc">
<!--- Switch among various fuses --->
<cfscript>
cfparam ("fuseaction", "");
switch(fuseaction) {
case "about": {
include("../pages/dsp_about.cfm");
break;
}
case "contact": {
include("../pages/dsp_contact.cfm");
break;
}
default: {}
break;
}
</cfscript>
Good luck,
[>] Jeff Howden
jeff at jeffhowden.com
http://jeffhowden.com/
More information about the thelist
mailing list