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

Global variable

Status
Not open for further replies.

noyes99

Programmer
Jun 25, 2002
38
IN
I am ( as you'll soon figure out) quite new to ColdFusion. I am basically a Vignette Story Server developer. What I am trying to do is to set a variable as a global variable so that I can retrieve its value anywhere within the page. How do i go about doing this?

thanks

PS : I know about session variable, but I am not sure if that is the right way. I only need a variable for the entire page. I want to access some values that that I set in the main body to be accessible in the footer.
 
if you have your main fale called lets say index.cfm and index.cfm includes a file called footer.cfm.

in index.cfm if you have got:

<CFSET something = &quot;a new value&quot;>

the variable something has been assigned to what is known as the variables scope, and is available until the page processing is complete. so the variable something will be accessiable in the page footer.cfm by referencing it like this:

<CFOUTPUT>
#variables.something#
</CFOUTPUT>

hope this helps!
 
The variable I am trying to access in the footer is a the result of a query, in one of the custom tags. It is not variable in the index.cfm file

-thanks
 
A 'global' variable as far as CF is concerned would be a variable in any of these scopes:

server
session
application
request

The REQUEST scope is valid in the current page until processing stops, but ALSO within any custom tags that may be run. I suspect a request variable is what you need.
Code:
<cfset request.ValidEverywhere = 1>
-Tek
 
thanks I got it working with Request. using a code something like this.

<CFSET Request.field_name1 = &quot;value&quot;>
<CFSET Request.field_name2 = &quot;value&quot;>
<CFSET Request.field_name3 = &quot;value&quot;>
...



<CFOUTPUT>#Request.field_name1#</CFOUTPUT>....

Thanks for all your help

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top