Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Using Dynamically-Generated Variables

New Here ,
Aug 09, 2008 Aug 09, 2008
I'm sure there's a CF function to do this, I'm just not familiar with it.

I've got a simple query named "people" that returns three names, say: "Amber, Bob, Chuck." Now, I want to generate variables with the name: xStreetName where 'x' would be replaced. I'm using a CFLOOP, so 'x' would actually be something like #people.name#. So, I'd be left with three variables named AmberStreetName, BobStreetName, and ChuckStreetName.

The dynamically generated variables then populate a blank form. The user will then submit the Street Name values for Amber, Bob and Chuck.

On the next page, I'd like to use a dynamically-generated SQL statement to add both the dynamically-generated variable name and the associated values to a database.
306
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 09, 2008 Aug 09, 2008
variables[variablepart & "contstantpart"]

Storing the variable name seems like a bad idea.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 20, 2008 Aug 20, 2008
LATEST
<!--- ============================================================== --->
<cffunction name="field_set" output="No">
<cfargument name="field" type="string" default="">
<cfargument name="value" type="string" default="">

<cfset "#field#"= value>
</cffunction>
<!--- ============================================================== --->
<cffunction name="field_get" output="No">
<cfargument name="field" type="string" default="">
<cfif isdefined("#field#") IS TRUE>
<cfreturn evaluate("#field#")>
</cfif>
</cffunction>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources