Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic variables

Status
Not open for further replies.

SirGalaahad

Programmer
Apr 9, 2001
3
DE
Hello,

i have some problems with dynamic variables. I have a form with the textareas named (for example) Link, Text, Cur_Date. After posting they are named Form.Link, Form.Text and Form.Cur_Date.
In my database i have the following columns:

Name | Value
-------------------
Link | 123
Text | abc
Cur_Date | today

So when I start the query the variable #Name# has the values Link, Text and Cur_Date. Now it comes:
In the <cfoutput> Tag i use the following <cfset> Tag:
<cfset myvariable = &quot;Form.#Name#&quot;>
With <cfset &quot;#myvariable#&quot; = &quot;some value&quot;> I can assign my form variables new values, but how can I read from my variables?

I need something like:

<cfoutput>
&quot;#myvariable#&quot;
</cfoutput>

should be equal to (for #Name# = &quot;Link&quot;):

<cfoutput>
#Form.Link#
</cfoutput>

Thanks,
Rene Guenther
 
if you <cfset myvariable = &quot;Form.#Name#&quot;>
and then <cfoutput>#myvariable#</cfoutput>
what do you get ? don't you get Form.Link ???? yes ?
so it's fine, you've got its name, and to get its value, only #eval(&quot;#myvariable#&quot;)# or something
 
Hey Rene,

I think <cfoutput>#evaluate(&quot;Form.#Name#&quot;)#</cfoutput> will give you what you want.

Hope this helps,
GJ
 
Thanks! Thats the solution which will shorten my code immensly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top