views:

41

answers:

1

I have a form where everything is supposed to be disabled on load except the first field.
The first field is an autocomplete input. When they select something from it, it goes disabled, and then sets the second field to be enabled. The second field is a dropdown.

The problem is, after a user uses the form and clicks the back button, it goes to a state similar to the one it was in before they clicked submit-- 1- autocomplete is disabled (but has no value for some reason) 2- dropdown is enabled, and set to the value they submitted with

I've tried to force the restoration of the form with javascript (using jquery's .ready()), but the .ready() doesn't run after they go back with the back button..

Refreshing the page after going back restores it. Any ideas how I can fix this?

A: 

The problem is that browsers are inconsistent in how they handle the back button. Firefox, for example, caches the state of the HTML (post-Javascript processing) and returns to that state after hitting the back button, but some others don't.

The best thing for you to do is after the submit, you should redirect to a URL that contains HTML representing the submitted data with the ability to edit those submitted details. This will give your users less of a desire to want to hit the back button.

Edit:

You should also add this to your page:

<meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate"> 

That is supposed to prevent browsers from caching the changes of the page's state. I assume you'd prefer it so that when the user hits the back button they start from the beginning state of the page.

Jacob
that's a good idea.i'm going to take this as an answer, but out of curiosity, is there any solution to this problem? im thinking it might be possible with some server side tricks (e.g. refreshing the page from php when they go back)
babonk
"but others don't." -- I suggest you change this to "but some others don't." Opera does something similar to what Firefox does (though I like how Opera does it better), and there may be other browsers which keep the state, too (elinks comes to mind).
strager
Good clarification, strager.
Jacob