I have a <select>
on my page.
When you select an option from this select
the form submits and the page reloads.
Now I want only when you enter for the first time the page to have a preselected option but when you select an option from the select it should remain the option you selected even if the page reloads.
Is this possible with javascript?
Asked
Active
Viewed 290 times
0

Sapan Diwakar
- 10,480
- 6
- 33
- 43

hhh3112
- 2,167
- 10
- 36
- 55
-
1Not with JavaScript alone, but you can use cookies to persist the value. – Felix Kling Mar 07 '12 at 13:23
-
Here is a question that might help you: http://stackoverflow.com/questions/2358689/jquery-cookies-setting-select-drop-down-value-after-page-refresh – alekwisnia Mar 07 '12 at 13:30
1 Answers
0
The client does not remember the previus state of the page. So the selected value will be missed after the postback.
If you can modify the server side code then you can post the selected value back and forth: when the page reload, the value is again available to the client.

Alberto De Caro
- 5,147
- 9
- 47
- 73