Chapter 1: ColdFusion Tags
129
CFLOOP
Looping is a very powerful programming technique that lets you repeat a set of
instructions or display output over and over until one or more conditions are met.
CFLOOP supports five different types of loops:
•
Index Loops
•
Conditional Loops
•
Looping over a Query
•
Looping over a List
•
Looping over a COM Collection or Structure
The type of loop is determined by the attributes of the CFLOOP tag.
Index Loops
An index loop repeats for a number of times determined by a range of numeric values.
Index loops are commonly known as FOR loops, as in "loop FOR this range of values. "
Syntax
<CFLOOP INDEX="parameter_name"
FROM="beginning_value"
TO="ending_value"
STEP="increment">
...
HTML or CFML code to execute
...
</CFLOOP>
INDEX
Required. Defines the parameter that is the index value. The index value will be set
to the FROM value and then incremented by 1 (or the STEP value) until it equals
the TO value.
FROM
Required. The beginning value of the index.
TO
Required. The ending value of the index.
STEP
Optional. Default is 1. Sets the value by which the loop INDEX value is
incremented each time the loop is processed.
Examples
In this example, the INDEX variable is incremented for each iteration of the loop. The
following code loops five times, displaying the INDEX value of the loop each time:
<CFLOOP INDEX="LoopCount"
Summary of Contents for COLDFUSION 4.5-CFML LANGUAGE
Page 1: ...Allaire Corporation CFML Language Reference ColdFusion 4 5...
Page 207: ...Chapter 1 ColdFusion Tags 183 CFCATCH CFTRY BODY HTML...
Page 224: ...200 CFMLLanguageReference CFOUTPUT P Text within CFOUTPUT is always shown CFOUTPUT BODY HTML...
Page 336: ...312 CFMLLanguageReference CFIF BODY HTML...
Page 404: ...380 CFMLLanguageReference DE It is morning CFOUTPUT P BODY HTML...
Page 413: ...Chapter 2 ColdFusion Functions 389 Customer BalanceDue BR CFOUTPUT CFIF BODY HTML...
Page 483: ...Chapter 2 ColdFusion Functions 459 CFOUTPUT CFLOOP BODY HTML...
Page 584: ...560 CFMLLanguageReference...
Page 594: ...570 CFMLLanguageReference...