...

View Full Version : Maintaining selected values when you click 'back'



Spudhead
05-20-2005, 12:48 PM
I've got a form. With some select boxes, and text inputs and all sorts of stuff like that. It submits to a page. That page has a "back" link on it - a simple javascript history.go type one. When you click it, you go back to the form. All the text inputs on the form have kept the values that you typed in. This is good. But only some of the select boxes have kept their selected values; the rest have reverted to the first value in their option list.

This is in IE 6. In Firefox 1.0.4 none of the select boxes have kept their values. As far as I knew, you couldn't do what IE appears to be doing without scripting it.

Why is IE keeping the selected values of some select boxes? What governs this behaviour? I can live with it losing all the values, or keeping all the values. But not keeping some and forgetting about others :confused:

glenngv
05-20-2005, 01:46 PM
It's easier if you just reset all the selections and default text values.

<body onload="document.theForm.reset()">

Spudhead
05-20-2005, 03:32 PM
Yes, it is, but... I have a feeling that the people who are testing this particular site are going to be asking questions along the lines of "You can make it keep what I entered for those boxes, why can't you do it for these ones over here on the same page?" and all I'm going to be able to answer is "I don't know" :(

mark87
05-20-2005, 03:52 PM
You could use cookies to store the information they enter, then retrieve the cookie when the form page is opened?

glenngv
05-23-2005, 04:36 AM
Yes, it is, but... I have a feeling that the people who are testing this particular site are going to be asking questions along the lines of "You can make it keep what I entered for those boxes, why can't you do it for these ones over here on the same page?" and all I'm going to be able to answer is "I don't know" :(I thought you can live with it losing all values?

I can live with losing all the values
Actually, I haven't duplicated what you experienced in IE6 and Firefox resetting some select values. I created a sample page and tested with those browsers and all the previous selections were retained. Probably your comboboxes are programmatically created by Javascript? If it is, then the only solution is to use cookies as mark87 suggested. When the page is submitted and being processed (I assume you're using a server-side language for this), you store the data in cookies. And onload of the form, set the default values of the fields based from the retrieved cookies.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum