1 Reply Latest reply on Aug 21, 2017 5:14 AM by BKBK

    cfloop :  to annotate the different elements of a list

    ZNB Level 1

      Hello,

      I would like to be able to annotate the different elements of a list made with a cfloop.

      I do not know how to do it.

      Thank you for your help.
      cfloop.gif

        • 1. Re: cfloop :  to annotate the different elements of a list
          BKBK Adobe Community Professional & MVP

          It's unclear what you mean by "annotate the different elements of a list". By definition, each element in a list has a position. Couldn't you use that as annotation?

           

          In any case, you could store the list elements in an array. It would then take just one function call to convert back to list. The thinking goes like this

           

          <cfset elements = arrayNew(1)>

           

          <cfloop index="idx" from="1" to="5">

              <cfswitch expression="#idx#">

                  <cfcase value="1" >

                      <cfset elements[idx] = "Genre">

                  </cfcase>

                  <cfcase value="2" >

                      <cfset elements[idx] = "Nom">

                  </cfcase>

                  <cfcase value="3" >

                      <cfset elements[idx] = "Prénom">

                  </cfcase>

                  <cfcase value="4" >

                      <cfset elements[idx] = "Code postal">

                  </cfcase>

                  <cfcase value="5" >

                      <cfset elements[idx] = "Ville :">

                  </cfcase>          

              </cfswitch>

          </cfloop>

           

          <cfoutput>#arrayToList(elements)#</cfoutput>