Highlighted

cfloop : to annotate the different elements of a list

Participant ,
Aug 20, 2017

Copy link to clipboard

Copied

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

Views

188

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

cfloop : to annotate the different elements of a list

Participant ,
Aug 20, 2017

Copy link to clipboard

Copied

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

Views

189

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 20, 2017 0
BKBK LATEST
Adobe Community Professional ,
Aug 21, 2017

Copy link to clipboard

Copied

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>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 21, 2017 0