How to loop over a list in ColdFusion

cfloop - loop over a list

cflooplist.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 loop over a list in coldfusion</title>
</head>

<body>
<h2 style="color:Crimson">cfloop Tag Example: List</h2>

<cfloop list="Jenny,Jones,John,Ben,Raymond,Kak" index="ListElement" delimiters=",">
 <cfoutput>
  <b>Current List Element:</b> #ListElement#<br />
 </cfoutput>
</cfloop>

<br /><br />
<cfset CityList="Rome;London;NewYork">
<cfoutput>
 <b>CityList:</b> #CityList#<br />
</cfoutput>

<cfloop list="#CityList#" index="ListElement" delimiters=";">
 <cfoutput>
  <b>Current List Element:</b> #ListElement#<br />
 </cfoutput>
</cfloop>

</body>
</html>







More ColdFusion examples