CFLOOP

I l @ ve RuBoard

<CFLOOP>

Used to repeat a specific piece of code over and over while certain conditions are met.

Syntax

For Index Loop:

 <cfloop index="name_of_index"          from="value_to_start_on"         to="value_to_end_on">   Code to be executed </cfloop> 

For List Loop:

 <cfloop index="name_of_index"          list="name_of_list"         delimiters="character_used_for_delimiter">   Code to be executed </cfloop> 

Other types of loops include conditional loops and loops over queries.

Attributes

Index: Required. In an index loop, the index is a ColdFusion variable that holds the current place in the loop, starting at the From value and adding 1 for each iteration of the loop. In a list loop, the Index attribute holds the value of the current item in the list. If you are on the third iteration of the loop, it will hold the value of the third item in the list.

From: Required. The number on which to start the loop.

To: Required. The number on which to end the loop.

Delimiters: Optional. The character used to separate the values in the list. The default is a comma.

Example

Index Loop:

 <!--- use looping to count to 10 --->  <cfloop from="1"         to="10"         index="i">  <cfoutput>    #i#<br>  </cfoutput> </cfloop> 

List Loop:

 <!--- looping to loop over a list and output each value --->  <cfloop list="#url.list#"         delimiters=","         index="i">   <cfoutput>     The current value in the list is: #I#<br>   </cfoutput>   </cfloop> 
I l @ ve RuBoard


Macromedia ColdFusion 5. Training from the Source
Macromedia ColdFusion 5 Training from the Source (With CD-ROM)
ISBN: 0201758474
EAN: 2147483647
Year: 2002
Pages: 99
Authors: Kevin Schmidt

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