Solved

Variable Problem from page to page

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now