Cfloop: Index Loop - MACROMEDIA COLDFUSION MX 61-CFML Reference

Cfml reference
Hide thumbs Also See for COLDFUSION MX 61-CFML:
Table of Contents

Advertisement

cfloop: index loop

Description
An index loop repeats for a number of times that is determined by a numeric value. An index loop
is also known as a FOR loop.
Syntax
<cfloop
index = "parameter_name"
from = "beginning_value"
to = "ending_value"
step = "increment">
... HTML or CFML code ...
</cfloop>
See also
cfabort, cfbreak, cfdirectory, cfexecute, cfexit, cfif, cflocation, cfrethrow,
cfswitch, cfthrow,
Attributes
Attribute
Req/Opt Default
index
Required
from
Required
to
Required
step
Optional
Usage
Using anything other than integer values in the
product unexpected results. For example, if you increment through an index loop from 1 to 2,
with a step of 0.1, ColdFusion outputs "1,1.1,1.2,...,1.9", but not "2". This is a programming
language problem regarding the internal representation of floating point numbers.
Note: The to value is evaluated once, when the cfloop tag is encountered. Any change to this value
within the loop block, or within the expression that evaluates to this value, does not affect the number
of times the loop is executed.
Example
In this example, the code loops five times, displaying the
<cfloop index = "LoopCount" from = "1" to = "5">
The loop index is <cfoutput>#LoopCount#</cfoutput>.<br>
</cfloop>
The output of this loop is as follows:
The loop index is 1.
The loop index is 2.
The loop index is 3.
The loop index is 4.
The loop index is 5.
cftry
Description
Index value. ColdFusion sets it to
decrements by
Beginning value of index.
Ending value of index.
1
Step by which to increment or decrement the index value.
from
value, until it equals
step
and
attributes of an index loop can
from
to
value each time:
index
value and increments or
value.
to
cfloop: index loop
233

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents