0
Using Dynamically-Generated Variables
New Here
,
/t5/coldfusion-discussions/using-dynamically-generated-variables/td-p/173226
Aug 09, 2008
Aug 09, 2008
Copy link to clipboard
Copied
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.
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/using-dynamically-generated-variables/m-p/173227#M15730
Aug 09, 2008
Aug 09, 2008
Copy link to clipboard
Copied
variables[variablepart & "contstantpart"]
Storing the variable name seems like a bad idea.
Storing the variable name seems like a bad idea.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Participant
,
LATEST
/t5/coldfusion-discussions/using-dynamically-generated-variables/m-p/173228#M15731
Aug 20, 2008
Aug 20, 2008
Copy link to clipboard
Copied
<!---
==============================================================
--->
<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>
<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>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

