Drop downs being reset after back button pressed in IE

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
marty pain
Forum Contributor
Posts: 105
Joined: Thu Jun 11, 2009 5:32 am
Location: Essex

Drop downs being reset after back button pressed in IE

Post by marty pain »

I'm working on this site and I can't get round this problem. It's fine in Firefox, but not IE. I have heard it might have something to do with caching, but don't know how to change it.

This is what happens:
When the page is generated it creates a drop down list, using javascript, of countries. This information is taken from a back office system. These countries then relate to a destinations drop down, also created in javascript. When the user selects a country, the destination drop down updates to give you all the destinations for that country.

example:
Country choices: America, China, France, UK.

France choices: Cannes, Paris, Nice.

The User selects France, the destination drop down changes to include the above options. The user selects Paris and then gives his name and address. The user then clicks continue and moves on to the next page. On the next page a summary of his selections and details is displayed. The user realises that he entered his address in wrong, so clicks the back button. When he goes back to the first page, the destination drop down resets back to Cannes! It should have held the selection (Paris)

Can anyone help?? It's starting to realy do my head in! :banghead:

Thanks!
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: Drop downs being reset after back button pressed in IE

Post by kaszu »

should have held the selection (Paris)
and why is that? Just because FF does it, doesn't mean that's a standard or IE should.

Make sure that you call a function to fill cities dropdown onload event.
marty pain
Forum Contributor
Posts: 105
Joined: Thu Jun 11, 2009 5:32 am
Location: Essex

Re: Drop downs being reset after back button pressed in IE

Post by marty pain »

The reason it should state Paris is because that was the state of the page when the page was posted. When I go back to a page I expect (same as most everyday users) that the selections should be in the same state as they were when the page was posted.

Firefox works as it knows the page isn't being loaded, it's just shows it in it's last state (probably just from cache). When using the back button the onload event isn't run as, technically, the page isn't being loaded, just re-displayed. This works well and behaves as most users would expect.

You are right though. I shouldn't expect IE to work in a user friendly way.

To overcome the IE problem, I save the selection in a hidden text box and added code to the onload event so that this is used to select the item in the list. When IE runs the onload event the list is created and the selection with the same text as the hidden text box is selected.
Post Reply