|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
History.back() problem
I have a form on my site, that when filled out and submitted will validate things like email address, phone #, etc. If there is something amiss, a validation screen (new page) will appear with the errors found. I added a link there to go back to the form to make corrections using both javascript:window.history.back() and just javascript:history.back().
But when returning to the form, the form is blank using either of the above, and the user will have to fill the whole form out again. I know at one time the form data was sticking when retuning, but nothing has changed coding wise. This occurs in both IE and Firefox. Any way to go back in history and keep form data? |
|
#2
|
||||
|
||||
|
cookie?
Hi tcustomgolf, welcome to the forums,
I think the best way to solve this may be to set and read a cookie. Initial page load, no cookie to read - inputs empty on submit cookie set, user sent to validation page on return to first page, cookie read - inputs use cookie values. |
|
#3
|
||||
|
||||
|
i agree with Mittineague, the form data is stored by the browser normally so think of it this way, dont expect anything that happens in the browsers (dont take anything for granted) because it most likley is a feature of the browser itself.
colton22
__________________
![]() Hang Out, Listen To Music, Have Fun, and Customize Your Experiance All In One Place! - Colton22's World - This is My World |
|
#4
|
|||
|
|||
|
Try this:
Code:
out.println("<HTML><HEAD><title>JavaScriptExample</title>");
out.println("<SCRIPT LANGUAGE=JavaScript>");
out.println("function back() {");
out.println("history.back(-1);");
out.println("}");
out.println("</SCRIPT>");
out.println("</HEAD>");
...<some HTML>..
|
|
#5
|
|||
|
|||
|
Well, a very simple solution would be to send the user back to the form page
as if he pressed the back button in his browser, that will retain the form items he filled out. Like so: Code:
<a href='javascript:window.history.back()'>Please correct your form</a> Of course, you can have your JavaScript function do it like so: Code:
setTimeout("window.history.back()",5000); // 5 second delay
Otherwise you would have to send data back to the original form page and fill in the form items. You can send hidden form items from the validation page back to the original form page, on the original page you would check if those values are empty or zero for when the user goes there the first time. See if the back method works for you, if it doesn't and you need more detailed information (and code) on the other method I somewhat described just ask. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > History.back() problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|