Im trying to figure out the best wasy to loop over an array, but limit one loop to the first five positions. Then in a separate loop display the rest of the array.

I am limited to what I can use. Meaning we code everything within cfscript tags in our cfc's. Therefore I cant use cfsets or such.
Here is my cfloop now:

<cfloop from="1" to="#variables.albumEdit.albumCnt#" index="i">
        <li id="article_1"><input type="hidden" name="trackList" value="#variables.albumEdit.albumName[i]#" />
        <span class="attribute album-title">#variables.albumEdit.albumName[i]#</span>
        <span class="attribute album-status">#variables.albumEdit.prodStatus[i]#</span><cfloop from="1" to="#variables.albumEdit.albumCnt#" index="i">
        <li id="article_1"><input type="hidden" name="trackList" value="#variables.albumEdit.albumName[i]#" />
        <span class="attribute album-title">#variables.albumEdit.albumName[i]#</span>
        <span class="attribute album-status">#variables.albumEdit.prodStatus[i]#</span>
        <span class="attribute genre">Rock</span>
        <span class="attribute release-date">#variables.albumEdit.releaseDate[i]#</span>
        <span class="attribute track-list"><a href="index.cfm?action=younger.trackListEdit&prodID=#variables.albumEdit.prodID[i]#">Edit Tracks</a></span>
      <div class="controls">
         <a class="button secondary" href="index.cfm?action=younger.gcaAlbumDetailEdit&prodID=#variables.albumEdit.prodID[i]#">Edit</a>
      </div>
      </li>
      </cfloop>

ok I tried editing this to add additional info. I need to loop over the first 5 arrays, then have another loop to output any remaining data greater than 5. Thanks for any help.

I need to loop over the first 5 arrays, then have another loop to output any remaining data greater than 5

If you elements, can't you just loop twice? Loop from 1-5, if there are enough elements

   <cfset firstLoopMax = Min(variables.albumEdit.albumCnt, 5)>
   <cfset lastShownIndex  = 1>
   <cfloop from="1" to="#firstLoopMax#" index="i">       
       ... show element ...
       <!--- track displayed index --->
       <cfset lastShownIndex = lastShownIndex + 1>
   </cfloop>

Then loop again to show the remaining elements

   <cfloop from="#lastShownIndex#" to="#variables.albumEdit.albumCnt#" index="i">       
       ... show element ...
   </cfloop>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.