Solved

Variable Problem from page to page

Posted on 2002-04-30
4
180 Views
Last Modified: 2013-12-24
If I create a variable using

<CFSET NumStores = GetMCStoreCodes.RecordCount>

right after a query, it holds the value on that page but when I get to the action page specified in the <CFFORM> it loses it's value.  What do I need to retain this value from page to page?  I thought this was an application variable and that application variables keep their value for 2 days and page to page. Be speciffic.
0
Comment
Question by:Anadaboy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 19

Expert Comment

by:cheekycj
ID: 6982118
to set an application level var do this:

<cflock timeout="" throwontimeout="Yes" type="EXCLUSIVE" scope="APPLICATION">
  <cfset APPLICATION.NumStores = GetMCStoreCodes.RecordCount>
</cflock>

make sure you have application management on using application.cfm

CJ
0
 
LVL 19

Accepted Solution

by:
cheekycj earned 200 total points
ID: 6982124
If you just want the data passed to the next page then you can use either SESSION or URL params or a hidden form field.

for hidden form field add this to your cfform:

<input type="hidden" name="NumStores" value="#GetMCStoreCodes.RecordCount#">

you can access it on the action page using FORM.NumStores.

You can also use URL parameters it works the same as the FORM code above but gets passed via the URL and accessed via URL.NumStores

the third and final option would be session data.

Again you need to make sure application.cfm exists and has session/application managment enabled (look at your cf documentation for sample application.cfm code.. it is very simple)

Now for session var use:

<cflock timeout="" throwontimeout="Yes" type="EXCLUSIVE" scope="SESSION">
 <cfset SESSION.NumStores = GetMCStoreCodes.RecordCount>
</cflock>

you can access this on the action page using: SESSION.NumStores.

BTW: in my first comment you can access the variable in the action page using APPLICATION.NumStores

HTH,
CJ
0
 

Author Comment

by:Anadaboy
ID: 6984933
Multiple ideas from one question.  You're great.  Thanks again.
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 6986127
No problem, Glad I could help and Thanx for the "A"
0

Featured Post

Don't Miss ATEN at InfoComm 2017!

Visit booth #2167 to see the  new ATEN VM3200 32 x 32 Modular Matrix Switch. Other highlights include the VE8950 4K HDMI Over IP Extender, VS1912 12-Port DP Video Wall Media Player  and VK2100 ATEN Control System. Register now with Free Pass Code ATEN288!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question