Skip to main content
February 17, 2009
Question

Create cfset with cfloop?

  • February 17, 2009
  • 1 reply
  • 296 views
I need to be able to iterate through some submitted form variables, and create a cfset for each. Unfortunately, what I have tried isn't working. Any thoughts?

Current code below:

<cfloop list="#fieldnames#" index="i">
<cfset client.#i#="#Evaluate(i)#">
</cfloop>
    This topic has been closed for replies.

    1 reply

    Inspiring
    February 17, 2009
    use associative array notation:

    <cfloop list="#form.fieldnames#" index="field">
    <cfset client[field] = form[field]>
    </cfloop>

    make sure none of your form's fields have name as one of reserved
    client-scope vars!!!

    reserved client scope vars:
    Client.CFID
    Client.CFToken
    Client.HitCount
    Client.LastVisit
    Client.TimeCreated
    Client.URLToken

    hth

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    February 17, 2009
    Excellent. Thank you very much.