Nested Loops

Like the <cfif> and <cfswitch> statements, loops can be nested. Nesting loops lets you create extremely powerful code, as long as you are very careful in constructing the loops. Listing 9.13 contains a practical example of nested loops, using three loops to display a table of Web browser–safe colors (seen in Figure 9.10). Save the code as loop3.cfm.

Figure 9.10. Displaying the Web browser–safe color palette requires the use of three nested loops.
Listing 9.13. loop3.cfm
<!--- Name: loop3.cfm Author: Ben Forta (ben@forta.com) Description: Demonstrate use of nested loops Created: 07/01/2007 ---> <html> <head> ...

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.