O'Reilly logo

Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started by Charlie Arehart, Raymond Camden, Ben Forta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Switch Statements

All the conditional processing used thus far has involved <cfif> statements. But as I stated at the beginning of this chapter, ColdFusion also supports another form of conditional processing: switch statements.

The best way to understand switch statements is to see them used. Listing 9.10 should be saved as file switch.cfm.

When you have executed Listing 9.10, you’ll notice that it does exactly what Listing 9.5 (file if5.cfm) does. The code here is very different, however.

Listing 9.10. switch.cfm
<!--- Name: switch.cfm Author: Ben Forta (ben@forta.com) Description: Demonstrate use of <cfswitch> and <cfcase> Created: 07/01/2007 ---> <html> <head> <title>Switch</title> </head> <body> <!--- Get day of week ---> <cfset dow=DayOfWeek(Now())> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required