Passing variables
I inherited a Club website and a copy of CF for Dummies. All went well until my ISP upgraded. Now I can't pass variables between pages. What to do?
I inherited a Club website and a copy of CF for Dummies. All went well until my ISP upgraded. Now I can't pass variables between pages. What to do?
Until now I have never had to deal with scopes. I was able to pass variables between templates by using
<a href="nextpage.cfm?varmy=#xyz#">Click</a> or in the "Action" section of a form. What kind of scope do I now need to pass a variable between templates? How and where do I define the scope?
Using
<cfset this.searchimplicitscopes=true>
is tempting, but the documentation says it will soon disappear.
Let's take your previous example:
Testsend.cfm
<html>
<head><!--- Nothing ---></head>
<body><cfoutput><a href = "testreceive.cfm?varmy=10">Click</a></cfoutput></body>
</html>
Testreceive.cfm
<html>
<head> <!--- Nothing ---></head>
<body><cfoutput>Received variable: #varmy#<br></cfoutput></body>
</html>
Since varmy is a URL variable, that is, one that comes in through the query string, you should "scope" it as follows:
<body><cfoutput>Received variable: #url.varmy#<br></cfoutput></body>
Yes, the documentation says there will be no searchImplicitScopes flag from ColdFusion 2025 onwards.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.