How to perform conditional loop in ColdFusion

cfloop - conditional loop

cfloopconditional.cfm



<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>cfloop tag example: how to use conditional loop in coldfusion</title>
</head>

<body>
<h2 style="color:Crimson">cfloop Tag Example: conditional</h2>
<cfset LoopEndPosition=5>
<cfoutput>
 <b>Loop End Position:</b> #LoopEndPosition#
</cfoutput>
<br /><br />

<cfset Counter=0>
Loop Start...<br />
<cfloop condition="LoopEndPosition GT Counter">
 <cfset Counter=Counter+1>
    <cfoutput>
        <b>Current Position:</b> #Counter#<br />
    </cfoutput>
</cfloop>
Loop End...

</body>
</html>







More ColdFusion examples