ColdFusion® MX: From Static to Dynamic in 10 Steps By Barry Moore
Table of Contents
Step 4. Controlling Program Flow
Well, you've made it this far through Step 4, and I think you should give yourself a bit of a cheer. In this example, we are going to use looping to get ColdFusion to give us a bit of a pat on the back.
Open your text editor and type the code shown in Listing 4.3, or you can open the Cheer.cfm file from the CompletedFiles\Examples\Step04 folder.
Listing 4.3 Cheer.cfm
<HTML> <HEAD> <TITLE>ColdFusion Cheer</TITLE> </HEAD> <BODY> <H2>ColdFusion Cheer</H2> <!--- start loop using a STEP value of 2 ---> <CFLOOP INDEX="x" FROM="2" TO="8" STEP="2"> <CFOUTPUT> <B>#x#</B><BR> </CFOUTPUT> </CFLOOP> Who do we appreciate?<BR> G <CFLOOP INDEX="x" FROM="1" TO="10" > <CFOUTPUT>o</CFOUTPUT> </CFLOOP> team! </BODY> </HTML>
Save the file as Cheer.cfm into your Examples\Step04 folder.
Browse to the page. You should see something similar to the output shown in Figure 4.5.