• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Step 4. Controlling Program Flow > Example 4.3: A ColdFusion Cheer

Example 4.3: A ColdFusion Cheer

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.

1.
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>



2.
Save the file as Cheer.cfm into your Examples\Step04 folder.

3.
Browse to the page. You should see something similar to the output shown in Figure 4.5.

Figure 4.5. Cheer.cfm output.


  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint