Home arrow ColdFusion arrow Page 4 - Jump Start To ColdFusion MX
COLDFUSION

Jump Start To ColdFusion MX


Yearning to become a ColdFusion buff? If so, then start with this article -- Clint introduces us to ColdFusion MX using coding examples and great explanations.

Author Info:
By: Clint Tredway
Rating: 4 stars4 stars4 stars4 stars4 stars / 9
September 24, 2002
TABLE OF CONTENTS:
  1. · Jump Start To ColdFusion MX
  2. · What Is ColdFusion?
  3. · Showing The Results Of A Query
  4. · Looping In ColdFusion
  5. · Form Handling
  6. · Conclusion

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

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.
blog comments powered by Disqus
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...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials