?
Solved

how do I pass a value from a page to another page that is not in a form.

Posted on 2006-04-06
4
Medium Priority
?
212 Views
Last Modified: 2013-12-24
I am refreshing a form based on the selection of a combo box.  There is a value that was passed from a previous page and I want to keep that value to pass it in the refreshed page.
0
Comment
Question by:moyedokun
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Plucka earned 1000 total points
ID: 16398146
moyedokun,

Use url, session variables, cookies, lots of options.

But lets start with url.

<cflocation url="nextPage.cfm?employee=#employee#" />

on nextPage.cfm

you can access it using

#url.employee#

Regards
Plucka
0
 
LVL 13

Expert Comment

by:srikanthmadishetti
ID: 16398758
on the selection of a combo box submit the form and send the value in hidden type

using

<input type="hidden" name="variablename" value="#value#">

-s-
0
 
LVL 13

Expert Comment

by:srikanthmadishetti
ID: 16398794
oops sorry i didnt saw your question clearly

you can pass the variables url and another thing is that you can create a dummy form

like
<form name="" action "">
<input type="hidden" name="variablename" value="#value#">
</form>

onclick or onselection you can submit this form
0
 
LVL 9

Expert Comment

by:digicidal
ID: 16399540
I would either go with Plucka's example and send it via the url querystring or via sessions (which Plucka also mentioned).  Here would be an example of that for referrence.

<cfif IsDefined("FORM.mySubmittedValue")>
    <cflock type="exclusive" scope="session" timeout="10">
    <cfset SESSION.myStoredFormValue = FORM.mySubmittedValue>
    </cflock>
</cfif>

Now you can just referrence SESSION.myStoredFormValue anywhere you wanted to look at the form value.  If you only need one field then I'd recommend Plucka's URL placement instead.  However if you have 10 fields or something to do this will I'd just recommend using the SESSION method.  In fact if you want you could store the whole FORM scope in a SESSION variable like so:

<cfif IsDefined("FORM.mySubmittedValue")>
    <cflock type="exclusive" scope="session" timeout="10">
    <cfset SESSION.mySavedFormScope = structNew()>
    <cfset temp = structAppend(SESSION.mySavedFormScope,FORM)>
    </cflock>
</cfif>

Now you can referrence the previous form as many times as you like without issue.  The only thing is that you should clean up the session at the end of the process to reduce memory load.  To do that you would simply remove the SESSION key that you added in the first process (probably when you process the form data from the second page if there is one).

Where ever you want your cleanup done:
<cfif IsDefined("SESSION.mySavedFormScope")>
    <cflock type="exclusive" scope="session" timeout="10">
    <cfset temp = structDelete(SESSION,"mySavedFormScope")>
    </cflock>
</cfif>
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

840 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