Example 4.3: A ColdFusion Cheer

Team-Fly    

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.

  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.

    graphics/04fig05.gif


    Team-Fly    
    Top
     



    ColdFusion MX. From Static to Dynamic in 10 Steps
    ColdFusion MX: From Static to Dynamic in 10 Steps
    ISBN: 0735712964
    EAN: 2147483647
    Year: 2002
    Pages: 140
    Authors: Barry Moore

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net