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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic variable variable 1

Status
Not open for further replies.

ezbinden

Programmer
Aug 8, 2001
5
CH
I want to use very dynamic and variable variables in my site as follows:

birthday is the column where i want to write the date

this works:
------------
<cfset birthdayyear=&quot;01&quot;>
<cfset birthdaymonth=&quot;12&quot;>
<cfset birthdayday=&quot;24&quot;>

<cfset birthday=#createdate(birthdayyear, birthdaymonth, birthdayday)#>

<cfoutput>#birthday#</cfoutput>
------------
output:

{ts '2001-12-24 00:00:00'}
------------
the problem is now, that i want to change the column dynamically

for example:
------------
<cfset column=&quot;birthday&quot;>

<cfset #column#year=&quot;01&quot;>
<cfset #column#month=&quot;12&quot;>
<cfset #column#day=&quot;24&quot;>

<cfset #column#=#createdate(#column#year, #column#month, #column#day)#>

<cfoutput>#birthday#</cfoutput>
------------
output:

error
------------
my problem is now, that i can't set a variable using #output#. nor can i create a date using #output#.

is there a possibility to link different variables?

ezbinden
 
In order to create a dynamic variable, you simply put &quot;quotes&quot; around the variable name. Keep in mind, that a variable name must start with a letter, which it does the way you've got this set up.

So these would be OK values to make dynamic vars off of:
<cfset column=&quot;birthday&quot;>
<cfset column=&quot;b123&quot;>

And these would NOT be ok.
<cfset column=&quot;123&quot;>
<cfset column=&quot;2birthday&quot;>

You also need to use the Evaluate() function.

<cfset column=&quot;birthday&quot;>

<cfset &quot;#column#year&quot; = &quot;01&quot;>
<cfset &quot;#column#month&quot; = &quot;12&quot;>
<cfset &quot;#column#day&quot; = &quot;24&quot;>

<cfset &quot;#column#&quot; = #createdate(Evaluate(&quot;#column#year&quot;), Evaluate(&quot;#column#month&quot;), Evaluate(&quot;#column#day&quot;))#> - tleish
 
10q very much

the only thing i need more is:

#Evaluate(&quot;#column#&quot;)#

ezbinden
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top