Attribute | Required | Type | Default | Description |
---|---|---|---|---|
condition | true | string | Condition that manages the loop. Cannot contain math symbols like < , > or = . Must use ColdFusion text implementations like less than , lt , greater than , gt , equals or eq . |
Final value of x
is 5.
<cfset x = 0 />
<cfoutput>
<cfloop condition="x LT 5">
<cfset x++ />
<li>#x#</li>
</cfloop>
</cfoutput>
This will also have a line break between each line of HTML.
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<cfscript>
x = 0;
while (x LT 5) {
x = x + 1;
writeOutput('<li>' & x & '</li>');
}
</cfscript>
<cfscript>
x = 0;
while (x LT 5) {
x = x++;
writeOutput('<li>' & x & '</li>');
}
</cfscript>
The cfscript function
cfloop
has no support forcondition
.
Notice that the cfscript output is all on one line.
<li>one</li><li>two</li><li>three</li><li>four</li>