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

Looping Over a List

As you learned in Chapter 6, “Using ColdFusion Lists, Arrays, and Structures,” ColdFusion lists are strings that have a delimited structure. Usually, the delimiter character is a comma, but you're free to use whatever delimiter character you like. When you instruct ColdFusion to loop over a list, it performs the loop code once for each item in the list. As ColdFusion progresses through the list, it makes the value of the list item it's focused on available to you through an index variable.

To set up a loop over a list, you need to provide ColdFusion with a list to work with and a name for the index variable. You do so by using the list and index attributes of the <cfloop> tag, as illustrated in the following examples.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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