[jQuery] Select box (selectedIndex) problems in Internet Explorer (ie) on refresh and back buttons

[jQuery] Select box (selectedIndex) problems in Internet Explorer (ie) on refresh and back buttons


I am trying to come up with a workaround for the fact that IE does not
allow one to hide() option elements in a select box:
http://groups.google.com/group/jquery-en/browse_thread/thread/8c0cd83701397c/925696d05016bb22?lnk=gst&q=hide+select+options+ie#925696d05016bb22
I am doing that by using a jQuery plugin:
http://www.texotela.co.uk/code/jquery/select/
With my own restoreOptions() modification. All would work well if it
wasn't for IE!!!!!
My solution works great until one uses the "refresh" button or posts
the form and hits the back "back" button. When this happens, IE loses
the value that was selected in the child select box. I have traced
this to the fact that IE restores the DOM from the code on refresh but
has a problem getting the correct option that was selected before the
refresh (Firefox and Opera don't have this problem).
Example:
http://rcs-comp.com/code_examples/jquery_ie_select_refresh_problem/
Currently, the console in Firefox shows:
document ready(): Fri Nov 09 2007 18:20:17 GMT-0500 (Eastern Standard
Time)
option count: 10
initial index: 5
initial value: green_money
hidden value: green_money
value after: green_money
and after "refresh"
document ready(): Fri Nov 09 2007 18:21:16 GMT-0500 (Eastern Standard
Time)
option count: 10
initial index: 5
initial value: green_money
hidden value: green_money
value after: green_money
IE 7 (doesn't work in 6 either) shows:
document ready(): Fri Nov 9 18:21:44 EST 2007
option count: 10
initial index: 5
initial value: green_money
hidden value: green_money
value after: green_money
and after "refresh" (notice the second select box lost its value)
document ready(): Fri Nov 9 18:23:37 EST 2007
option count: 10
initial index: 2 <-- this is a problem
initial value: red_wagon <-- this is a problem
hidden value: green_money <-- this is what the value above should be
value after: -1
I have come up with a fix using a hidden form field. But I don't like
the solution and it results in an extra value being posted.
http://rcs-comp.com/code_examples/jquery_ie_select_refresh_problem/fixed.html
Any insights are much appreciated!!!!