Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Remembering <select> box value

9:57 am on Sep 2, 2009 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 25, 2005
votes: 0

I have 2 <Select> boxes

The 1st one is populated upon page load (PHP)
The 2nd one is populated via javascript (no page reload) depending on the 1st select box value.

Upon submit the page will display a preview of the user inputs, with 2 submit buttons [send] and [edit]

My problem is if the user choose to edit, how can I make it that 2nd select box remember its value since after a page reload the 2nd select box doesnt have any contents (options),

Adding options to the 2nd select box is triggered by the 1st select box hence the following code is not possible.

<option value="value_here>" selected>Text Here</option>

note : The 2 select boxes pulled values from a DB table.

12:37 pm on Sept 2, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 3, 2005
votes: 0

Try including an input type=hidden with no value on initial load, save result of second selection there, hopefully it will still be there on page reload.
2:23 pm on Sept 2, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 7, 2004
votes: 0

Stuff the values in the querystring?