ColdFusion
  Home arrow ColdFusion arrow Page 4 - Jump Start To ColdFusion MX
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
COLDFUSION

Jump Start To ColdFusion MX
By: Clint Tredway
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2002-09-24

    Table of Contents:
  • Jump Start To ColdFusion MX
  • What Is ColdFusion?
  • Showing The Results Of A Query
  • Looping In ColdFusion
  • Form Handling
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Jump Start To ColdFusion MX - Looping In ColdFusion


    (Page 4 of 6 )

    The next topic that I am going to cover is looping in ColdFusion. To loop through just about anything in ColdFusion, you would use the <cfloop> tag. With this tag you can loop through a query, a list, an array, a structure, do for loops, and conditional loops. I am going to cover just the basics here. To loop through a query use the query attribute of <cfloop> like this:

    <cfloop query="myQuery">
    HTML and CF code here
    </cfloop>


    Its that simple. Now, let's go through how to loop from one number to another and output that number:

    <cfloop from="1" to="100" index="number">
    <cfoutput>#number#</cfoutput><br>
    </cfloop>


    This is similar to a for loop that you would use in PHP or ASP. The index attribute is used in other pieces of code like output, or an if statement. Here’s how to loop through a list:

    <cfset myList="1,2,3,4,5,6,7,8,9">
    <cfloop list="#myList#" index="listItem">
    <cfoutput>#listItem#</cfoutput>
    </cfloop>


    There is an optional attribute – delimiter -- that allows you to specify the delimiter for a given list. The default delimiter is a comma. Now, to loop over a structure you would use the collection and item attributes like this:

    <cfset products = StructNew()>
    <cfset val = StructInsert(products, "Appliances ", "Dryer ")>
    <cfset val = StructInsert(products, "Furniture ", "Couch")>
    <cfset val = StructInsert(products, "Electronics ", "Tv ")>

    <cfloop collection="#products#" item="cartitem">
    #products#<br>
    #StructFind(products, cartitem)#<br><br>
    </cfloop>


    I know that I have not covered everything about loops, but this gives you the basics to start using them. In a more advanced article I delve into loops in greater detail.

    More ColdFusion Articles
    More By Clint Tredway


     

    COLDFUSION ARTICLES

    - Adobe ColdFusion Just Got More RAD
    - How to Access a SQL Anywhere Database with C...
    - CFXML: Probing XMLDOM in ColdFusion
    - Creating a Web Service with ColdFusion: the ...
    - CFAjax: What it is and How to Use it
    - Querying SQL 2000 Server from ColdFusion
    - Introduction to ColdFusion Markup Language, ...
    - Introduction to ColdFusion Markup Language
    - Databases and Dreamweaver MX 2004, concluded
    - Databases and Dreamweaver MX 2004
    - Welcome to Coldfusion MX 6.1, concluded
    - Welcome to Coldfusion MX 6.1
    - What You Must Know About ColdFusion Flow-Con...
    - What You Must Know About Operators in ColdFu...
    - Everything You Must Know About ColdFusion Va...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek