Solved

Preserving data in the form or session

Posted on 2004-04-12
15
238 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
  • 4
  • 4
  • 3
  • +1
15 Comments
 
LVL 9

Accepted Solution

by:
CFDevHead earned 125 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 125 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 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