Technology TidBits

Answers to various technical questions on php programming, mysql, linux, and many more categories.
25% off Hosting at HostGator.com:
Use Code techbits25



Why do my web forms lose data when I hit the back button?

Last updated: 06/17/2009
A common way to allow users to correct problems with their web form submission is to tell them to use their "back button".  You can also use javascript to send them back.  Either way, it's a quick way to have them make changes.
 
The assumption here is that when they go back to the form, the data (or most of it) they entered will still be there, so they can just correct the necessary fields and re-submit.  Sometimes, though, the data is "missing" - the form is empty when the user goes back. 

I'm not sure of all the causes, but one thing I found is that if you do javascript validation of the form using an "onsubmit" event in the <form> tag, the problem occurs. 

To work around this, I call my validation routine from the submit button - using a "onclick" event. 

This may not work in all cases, but it did in mine. 
blog comments powered by Disqus
Have your own Tech-bit to contribute? Submit it here

Other questions in this category:
How can I open a new window using Javascript?
How can I add a quick javascript error page to my cgi / php scripts
How can I validate a form that has brackets in the variable names?
How to refresh the parent window from a pop up window.
How can I submit data to a form from a pop-up window?
Configuring htmleditor to do file uploads using php
How can I easily hide / display a form or text on my website?
IE 7 gives me an "Unknown runtime error" when using ajax - how can I fix this?
How can I refresh the parent window from a pop-up
How to include Javascript into your html code



Powered by KnowledgebasePublisher 1.1
Host Gator
Content provided by Roberts WebForge, Inc.