Solved

Variable Problem from page to page

Posted on 2002-04-30
4
176 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
  • 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

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

829 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