Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Variable Problem from page to page

Posted on 2002-04-30
4
Medium Priority
?
190 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 800 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

824 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