Article:
  ColdFusion MX on Mac OS X, Part 3
Subject:   problem was with cfswitch syntax
Date:   2002-11-05 14:18:07
From:   adolph
Response to: cfswitch / cfcase ???

Sorry for needlessly adding another comment line....


I had a syntax error. If you want cfswitch to evaluate a specific variable, you should use <cfswitch expression="#variable#">, not <cfswitch expression="variable">. I was a little confused by the documentation in Programming ColdFusion, pg. 32, 33, 791.


So the solution was:


<cfparam name="switch_value" default="1">
<cfswitch expression="#switch_value#">
<cfcase value="1">
<h1>Value = 1</h1>
<cfset switch_value="2">
</cfcase>
<cfcase value="2">
<h1>Value = 2</h1>
</cfcase>
</cfswitch>
<hr>
<cfswitch expression="#switch_value#">
<cfcase value="1">
<h1>Value = 1</h1>
</cfcase>
<cfcase value="2">
<h1>Value = 2</h1>
</cfcase>
</cfswitch>
<form method="post">
<input type="text" name="switch_value" value="<cfoutput>#switch_value#</cfoutput>">
<input type="submit" name="Submit" value="Submit">
</form>

Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Works for me
    2002-11-06 10:27:55  anonymous2 [View]

    Your program works for me -- thou the logic is a little strange.

    Dick