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!

Inserting Variables 1

Status
Not open for further replies.

coldfused

Technical User
Jan 27, 2001
2,442
US
I have this:

Code:
<cfoutput query="GetSecondaryReligious" group="ID">
<cfoutput>#GetSecondaryReligious.Name#</cfoutput> |
</cfoutput>

I want to do this:

Code:
 <cfoutput query="GetSecondary#PageTitle#" group="ID">
<cfoutput>#GetSecondary#PageTitle#.Name#</cfoutput> | </cfoutput>

I want to insert a variable name so I can use this bit of code no matter what page it's own. How do I do this without it erroring out?

----------------------------------------
Always Learning...
 
Well to begin with, you can't do something like this anyway:
Code:
<cfoutput>[COLOR=red]#GetSecondary#[/color]PageTitle[COLOR=blue]#.Name#[/color]</cfoutput>

CF will error out regardless. CF will try to parse the portion in red and the portion in blue.

Instead, you'd need to do something like:
Code:
<cfif isdefined("PageTitiel")>
 <cfoutput>#GetSecondary###PageTitle###.Name#</cfoutput>
<cfelse>
<cfoutput>#GetSecondary#PageTitle#.Name#</cfoutput>
</cfif>

____________________________________
Just Imagine.
 
I assume that #pagetitle# will be something like "religious, technical, financial" etc and that those literal strings will also be present in the name of the query columns.. if so, maybe you want something like this:

Code:
#evaluate("getsecondary#pagetitle#.name")#

It will evaluate the #pagetitle# first and then treat the rest of inside the ""'s as the name of a variable.
 
Perfect jmille34 . Thanks so much.

Carl

----------------------------------------
Always Learning...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top