Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Preserving data in the form or session

Posted on 2004-04-12
15
Medium Priority
?
261 Views
Last Modified: 2013-12-24
How do i preserve  input data in text box or radio button, or menu,
0
Comment
Question by:asamuel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
  • +1
15 Comments
 
LVL 9

Accepted Solution

by:
CFDevHead earned 500 total points
ID: 10808036
Menu Example
Menu page:<br>
<a href="actionPage.cfm?testVar=This is a test">Menu One</a>

menu action page
<cfif IsDefined('url.testVar')>
      <cfset session.testVar=url.testVar>
<cfelse>
      <cfset session.testVar=false>
</cfif>


Input/radio Example

<form action="actionPage" method="post">
<input type="text" name="textOne">
<input type="radio"  name="radioTest" value="yes">
<input type="radio"  name="radioTest" value="no">

</form>

Input/radio action page
<cfif IsDefined('form.textOne')>
      <cfset session.textOne=form.textOne>
      <cfset session.radioTest=form.radioTest>
<cfelse>
      <cfset session.textOne=false>
      <cfset session.radioTest=false>
</cfif>
0
 
LVL 35

Assisted Solution

by:mrichmon
mrichmon earned 500 total points
ID: 10808044
Please see all of the options available at this thread :

http:Q_20946898.html

The choices are hidden variables, appending the form structure, session variables, etc.

The choices are discussed in the listed thread...

Here is another thread I found by doing a search that deals with this issue :

http:Q_10321053.html
0
 

Author Comment

by:asamuel
ID: 10808305
<cfparam name="form.custarget" default="">
<cfset session.hygeReq.custarget="">
<CFIF IsDefined("Form.custarget")>
  <CFSET SESSION.hygeReq.custarget = Form.custarget>
  </cfif>
<cfinput name="custarget" type="text" value="#session.hygeReq.custarget#" size="20" required="no" message="Please enter the Pulse target">

That is what i have so far and still when i submit and go back, i get blank
0
Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

 
LVL 35

Expert Comment

by:mrichmon
ID: 10808467
that should work.

My guess is taht if you just add this to the top of the page :

<cfparam name="form.custarget" default="">
<cfoutput>*#form.custarget#*</cfoutput>

That you will see :

**

Which means that form.custarget was not defined and so the default parameter of blank was used.
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 10808907
I'm not sure but I believe the following is what your after.
If not, it would help if you let us know what and where you want preserve data, in what process etc.?

<cfparam name="form.test1" default="">
<cfparam name="form.test2" default="">

<cfif isDefined("form.btnSubmit")>

      <!--- do your error checking here --->
      <!--- if everything is fine than perform whatever action you need to do here, for example; update, insert, delete etc. --->
      <!--- after finished do a cflocation here to another page --->
      <!--- if there was an error then do nothing and the form will be populated again with the values the user entered --->

</cfif>

<cfoutput>

<form method="post" action="">

<input type="text" name="test1" value="#form.test1#">
<input type="text" name="test1" value="#form.test2#">
<input type="submit" name="btnSubmit" value="Submit">

</form>

</cfoutput>

0
 

Author Comment

by:asamuel
ID: 10812514
hi mrichmon,
Still is not working, what do you think the problem is
0
 
LVL 9

Expert Comment

by:CFDevHead
ID: 10813939

the reason your session variable is blank is because you clear it every time you load this page unless you post to this page the session variable gets cleared

Your code which does not work
<cfparam name="form.custarget" default="">
<cfset session.hygeReq.custarget="">
<CFIF IsDefined("Form.custarget")>
  <CFSET SESSION.hygeReq.custarget = Form.custarget>
  </cfif>
<cfinput name="custarget" type="text" value="#session.hygeReq.custarget#" size="20" required="no" message="Please enter the Pulse target">

 My code which does work

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<cfparam name="form.custarget" default="">
<cfparam name="session.hygeReq.custarget" default="">

<CFIF Form.custarget is NOT "">
      <CFSET SESSION.hygeReq.custarget = Form.custarget>
</cfif>
<cfform method="post" action="index.cfm">  
<cfinput name="custarget" type="text" value="#session.hygeReq.custarget#" size="20" required="no" message="Please enter the Pulse target">
<input type="submit" value="Go" />
</cfform>

</body>
</html>

Also make sure have an application page with settings like this

<cfapplication       name='SpiralDev'
      clientmanagement='yes'
      clientstorage='cookie'
      setclientcookies='yes'
      sessionmanagement='yes'
      sessiontimeout='#CreateTimeSpan( 0,0,90,0)#'
      applicationtimeout='#CreateTimeSpan(0,5,30,0)#'>
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10814208
As I tried to show you with my test code and CFDevHead explained, unless you are posting to this page you are clearing your variable.

Did you try running the test code I gave?  If so did you notice ** with no text in between?  That is showing that you are clearing the session variable.

Another wway to see this is to remove the default="" from the cfqueryparam so that it will throw an error if it is not defined.  This is a way to visually see what we are trying to tell you...that you are resetting the variable in the session to blank.
0
 

Author Comment

by:asamuel
ID: 10815348
I know it is frustrating for me and you, I did exactly as you mention in your posting, even i copied so don't get any mistakes,
I am still get blank, the way i have it i have this form it has a lot of input fields, and submit button to another page, and the other page has  lot of input fields, and once click on submit on second page take you again to first page, and when i go back nothing,
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10815629
It is because when you go back you form.custarget is no longer defined (on the 2nd page) and so it gets overwritten with "" because of your cfparam

Did you try CFDevHead's modified code?

0
 

Author Comment

by:asamuel
ID: 10815659
Yes, that is what i used, I used his code,
0
 
LVL 9

Expert Comment

by:CFDevHead
ID: 10829411
do you have an application page?
0

Featured Post

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

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

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…
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
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, …

610 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