Multiple If Statements

There’s one more feature of <cfif> that you need to look at—support for multiple independent conditions (as opposed to one condition made up of multiple conditions).

The best way to explain this is with an example. In the previous listings, you displayed a message on weekends. But what if you wanted to display different messages on Sunday and Saturday? You could create multiple <cfif> </cfif> blocks, but there is a better way.

Listing 9.5 contains yet another version of the code; this time the file name should be if5.cfm.

Listing 9.5. if5.cfm
<!--- Name: if5.cfm Author: Ben Forta (ben@forta.com) Description: Demonstrate <cfelseif> use Created: 07/01/2007 ---> <html> <head> <title>If 5</title> </head> <body> <!--- Get day ...

Get Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.