Try this:

<cflock timeout="10" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
<cfset SESSION.queryParams = ArrayNew(1)>
</cflock>

<cfif isDefined("FORM.FIELDNAMES")>
<!--- Add Form Values --->
<cfloop index="fldName" list="#FORM.FIELDNAMES#">
<cflock timeout="10" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
<cfset SESSION.queryParams[arrayIndex].Value=StructFind(FORM,fldName)>
</cflock>
</cfloop>

I think that should do what you need?
</cfif>

Basically I have an array that I initialized somewhere else called SESSION.queryParams(), which is an array of structures

>A while back there was a thread that discussed the best way to create
>variables from a form submission.
>
>So instead of using a bunch of individual if statements like so:
>
><cfif isDefined("form.person1FirstName")>
>  <cfset session.stPerson1.person1FirstName = form.person1FirstName />
></cfif>
><cfif isDefined("form.person1LastName")>
>  <cfset session.stPerson1.person1LastName = form.person1LastName />
></cfif>
>
>It was suggested that one would use the following:
>
><cfset session.stPerson1 = duplicate(form) />
>
>And that works really well, but I was wondering if it is possible to use
>this method of creating variables to populate different structs...
>
>So on a single form page I have something like this:
>
><input type="text" name="person1FirstName" />
><input type="text" name="person2LastName" />
>
><input type="text" name="person2FirstName" />
><input type="text" name="person2LastName" />
>
>And on the action page instead of the following code, is it possible to use
>something like the above mentioned cfset with the duplicate function??
>
><cfif isDefined("form.person1FirstName")>
>  <cfset session.stPerson1.person1FirstName = form.person1FirstName />
></cfif>
><cfif isDefined("form.person1LastName")>
>  <cfset session.stPerson1.person1LastName = form.person1LastName />
></cfif>
>
><cfif isDefined("form.person2FirstName")>
>  <cfset session.stPerson2.person2FirstName = form.person2FirstName />
></cfif>
><cfif isDefined("form.person2LastName")>
>  <cfset session.stPerson2.person2LastName = form.person2LastName />
></cfif>
>
>Thanks in advance for any suggestions you may have.
>
>Nate
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to