[thelist] ColdFusion function for dynamic variable name?

Plunkett, Matt MPlunkett at msa.com
Tue Jul 10 12:55:19 CDT 2001


Howdy-

Is there a function in ColdFusion that will let me construct variable names
from strings and then use them as variables?  Hopefully the code below will
help:

I have two sets of form fields, one hidden and one from various inputs.  The
hidden ones are all called oldField1, oldField2, oldField3, and so on and
the others are called requestField1, requestField2, and so on.

I want to compare oldField1 to requestField1 and so on...as my imaginary
function Foo is trying to do.

<cfset listFields = "Field1, Field2, Field3, Field4">

<cfloop list="#listFields#" index="field" delimiters=",">
	<cfif (Foo("old" & #field#) is not Foo("request" & #field#))>
		<!--- Do whatever. --->
	</cfif>
</cfloop>

Thanks,
Matt




More information about the thelist mailing list