homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Preserving form data and history.back()
JavaScript history forms

10+ Year Member

Msg#: 388 posted 4:31 pm on May 6, 2003 (gmt 0)

I have a PHP-based form that allows for the upload of two images, in addition to some other user information such as name, company, etc. When the user submits the form, there is some validation that goes on in PHP to ensure that the image is of a certain type and resolution. If one of these tests fails, a message is displayed describing what happened and then I set up a little JavaScript link like such....

<a href="javascript:history.back();">Fix It</a>

To allow the user to return to the original form and re-upload the image. However, when you click on the link, nothing happens. It stays on the same page! If I use the back button in the browser--same thing. I should note that the window the form is in has been created by window.open() and is a window called new_window. I have tried using javascript:new_window.history.back(), to no avail :(

An obvious solution would be to pass all the form variables to the link and just do it via PHP. But I feel like just moving back should do the trick.

It doesn't appear that any caching is going on, but perhaps I just am looking in the wrong place. Anyone haev any idea or tips on preserving form data and using history.back()?

Thanks :)

Incidentally, you can test out the script here:
<sorry, no test URLs>

[edited by: tedster at 6:31 pm (utc) on May 6, 2003]



WebmasterWorld Senior Member 10+ Year Member

Msg#: 388 posted 4:39 pm on May 6, 2003 (gmt 0)

<a href="#" onclick="javascript:window.opener.history.go(-1);">back</a>


10+ Year Member

Msg#: 388 posted 5:30 pm on May 6, 2003 (gmt 0)

Thanks for the reply... I don't need the parent window to go back, the form is contained in new_window. I tried the syntax you used minus the 'opener' portion, but IE just ignores it when you click the link. It acts like it went back, but the form does not reappear. Very strange.


10+ Year Member

Msg#: 388 posted 6:30 pm on May 6, 2003 (gmt 0)

Just FYI, I don't think IE liked the fact that the original form and the processing script were the same. I put the form in a separate file and now using back() works fine.


WebmasterWorld Senior Member drdoc us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 388 posted 10:57 pm on May 6, 2003 (gmt 0)

I would skip the "back" idea completely. Why not display the form again, with all the data entered in already, and just an error message telling them what went wrong?

Don't trust every browser to remember the form data on back-click...

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved