General - can't preserve input field after refresh

Hello,

On load, if a select box as the option X selected, display a specific input field.
This works, because, after the validation, I go back to the previous page, and the input field is there.

However, if someone selects the option X of the selectbox, the input field appears, BUT, if a refresh is made, we lost that input field.

I understand this is a normal behavior since, we are on a client-side language, hence it should forget the previous state, but, what is the common workaround for dealing with this, in order to “preserve” the input field after refresh?

Márcio

I don’t know; instead I’ve seen people recommend indeed doing it from the back end… either with a php echo() or with an actual session… or, as part of a more complicated setup with Post-Redirect-Get.

On our pages, where I’ve got some Javascript running which hides or shows some parts of a form depending on an answer selected elsewhere, we use a session. This is partially because people are getting quotes and go through multiple pages of forms, so we needed people to be able to both hit the back button and see what they had filled in, but also make changes, hit refresh, whatever, and still not lose their data.

slightly off-topic tidbit
There is a difference between browsers… with select drop-downs, I notice I can refresh Firefox and some other browsers, and the selection remains, while Opera and Chrome and forget who else would go to whatever had “selected” attribute.

Thanks a lot, it is important those kind of questions and above all, those kind of answers cas it allow us to stop digging in wrong directions.

I was struggling with the window.onload for nothing. :s

Thanks a lot, I will take the server-side as an alternative.

And thanks for the not-that-much off-topic, is interesting to know that, before we arrive on a strange scenario like the one described. :slight_smile:

Regards,
Márcio

You might also look into saving their selections in a cookie so that you can reapply them.

Thanks. :slight_smile: Long ago I’ve heard of advantages in using session instead of cookies. I don’t know if they still apply today, but it’s sure a gap on my knowledge.

Thanks for showing me the possibilities.

Regards,
Márcio

I’m hazy on cookies myself, but the idea that immediately sprung to my mind in “sessions > cookies” is that you may have a user base who have cookies turned off. There are security implications too but I thought those could be taken care of with research.