Search code examples
coldfusioncfloop

Evaluate function


Is there a better way to write the following?

<cfloop list="#qry.Columnlist#" index="FieldName">
   <cfset "form.#FieldName#" = Evaluate("qry.#FieldName#")>
</cfloop>

This loop is assigning every field in the query to a corresponding form field. I understand the evaluate function is shunned.


Solution

  • <cfloop list="#qry.Columnlist#" index="FieldName">
        <cfset form[FieldName] = qry[FieldName][1]>
    </cfloop>
    

    ?