asamuel
asked on
Preserving data in the form or session
How do i preserve input data in text box or radio button, or menu,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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 #*</cfoutp ut>
That you will see :
**
Which means that form.custarget was not defined and so the default parameter of blank was used.
My guess is taht if you just add this to the top of the page :
<cfparam name="form.custarget" default="">
<cfoutput>*#form.custarget
That you will see :
**
Which means that form.custarget was not defined and so the default parameter of blank was used.
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>
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>
ASKER
hi mrichmon,
Still is not working, what do you think the problem is
Still is not working, what do you think the problem is
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.cu
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.cust
<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.cu
<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='#CreateTim
applicationtimeout='#Creat
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.
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.
ASKER
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,
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,
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?
Did you try CFDevHead's modified code?
ASKER
Yes, that is what i used, I used his code,
do you have an application page?
ASKER
<cfset session.hygeReq.custarget=
<CFIF IsDefined("Form.custarget"
<CFSET SESSION.hygeReq.custarget = Form.custarget>
</cfif>
<cfinput name="custarget" type="text" value="#session.hygeReq.cu
That is what i have so far and still when i submit and go back, i get blank