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

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.
moyedokunAsked:
Who is Participating?
 
PluckaCommented:
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
 
srikanthmadishettiCommented:
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
 
srikanthmadishettiCommented:
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
 
digicidalCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.