Miscellaneous
cycle()
Signature
Section titled “Signature”cycle() — returns any
Description
Section titled “Description”Cycles through list values every time it is called.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
values | string | yes | — | List of values to cycle through. |
name | string | yes | default | Name to give the cycle. Useful when you use multiple cycles on a page. |
Examples
Section titled “Examples”<!--- Alternating table row colors --->
<table>
<thead>
<tr>
<th>Name</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<cfoutput query="employees">
<tr class="##cycle("odd,even")##">
<td>##employees.name##</td>
<td>##employees.phone##</td>
</tr>
</cfoutput>
</tbody>
</table>
<!--- Alternating row colors and shrinking emphasis --->
<cfoutput query="employees" group="departmentId">
<div class="##cycle(values="even,odd", name="row")##">
<ul>
<cfoutput>
<cfset rank = cycle(values="president,vice-president,director,manager,specialist,intern", name="position")>
<li class="##rank##">##categories.categoryName##</li>
<cfset resetCycle("emphasis")>
</cfoutput>
</ul>
</div>
</cfoutput>