Catfish Posted January 16, 2009 Share Posted January 16, 2009 Hi ppl, When you put data into a form element and then submit the form, if you press the back button the form will have been reset to its default state. Is there a way to preserve the content that the user put into the form after it is submitted and the back button is pressed? Quote Link to comment https://forums.phpfreaks.com/topic/141144-solved-make-forms-retain-content/ Share on other sites More sharing options...
Maq Posted January 17, 2009 Share Posted January 17, 2009 You could use sessions. Quote Link to comment https://forums.phpfreaks.com/topic/141144-solved-make-forms-retain-content/#findComment-738798 Share on other sites More sharing options...
Catfish Posted January 17, 2009 Author Share Posted January 17, 2009 I don't actually want to store the data in a variable, I just want it to remain in the menus when the user presses the back button in the browser. I noticed that this feature happens in certain forms online and not others, and I also think it could depend on the browser software but I don't have any solid evidence that this is what controls it. Since I don't know what controls the preservation of the form data I was putting out here to see if anyone knew about it. It would be handy for me in my scripts if I could control such a feature, then the user could decide if they wanted to preserve form data as they perform data input - because common data elements could be kept in the form elements between each record submission thereby reducing the amount of typing required for a record to be input. Quote Link to comment https://forums.phpfreaks.com/topic/141144-solved-make-forms-retain-content/#findComment-738828 Share on other sites More sharing options...
Catfish Posted January 17, 2009 Author Share Posted January 17, 2009 This is the best solution I've found: http://answers.yahoo.com/question/index?qid=20080116063609AAh9Q2B Which links to: http://www.dynamicdrive.com/dynamicindex16/formremember2.htm A javascript that will retain form values for you globally over your webpages. This was better than his original script because there is no modification of the form HTML code required. (Better for me anyway) And it has a toggle option to turn it on or off which I will want in the future too. It seems that in PHP you have to manually store values you want using $_SESSION and write your scripts in a particular fashion to use the $_SESSION values and reinsert them into a form etc. In any case, this topic is as good as solved for my likings! Quote Link to comment https://forums.phpfreaks.com/topic/141144-solved-make-forms-retain-content/#findComment-738856 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.