I use the plugin above to "remove" the options I don't want to see.
But when I remove them, I "cache" them in a variable attached to the
select object.  I then provide a new function called restoreOptions()
which uses the data in the cache variable to add the options back into
the select box.  So a summary, would go something like this:

1) Remove unneeded options from select box to match parent select box
value
2) Parent select box is changed
3) Restore all the options that were previously removed (they are in a
different order at this point, but that doesn't matter for my use).
4) Remove unneeded options from select box to match new parent select
box value
(repeat as necessary)

So, the goal is to be able to hide (remove) / show (add) options from/
to a select box.  We can't just use $().hide() b/c IE doesn't support
hiding an option element.

The above works just fine, unless you are in IE and hit "refresh" or
go to the next page and hit "back".  IE reloads the page and DOM in
such a way that the selected index for the child select box is lost.
This is a serious situation since it can result in lost data in the
web application I am building.

The problem is caused because IE tries to reset the child element
based on the selectedIndex (instead of value).  But it does that after
it has reloaded the element (putting the options back in the select
box that were originally in the HTML source) but before the javascript
is run, which means that when it resets the selectedIndex, it resets
it to the wrong element.  Then, when the javascript is run, the
element that is selected (wrongly) gets removed by the JS, and the
value is then lost and the user must reset it.

There are two ways to work around this that I can see 1) use a hidden
input element to cache the value of the child select box, and then use
that to restore the option (I am using this solution); 2) use a cookie
to store the value of the child select box

Neither are good options IMO.  I would like to find a cleaner
solution.  I would like to find a way to keep the child element from
losing its value in IE using an unobtrusive and reliable solution.

Does that help?

On Nov 14, 4:15 pm, Flesler <[EMAIL PROTECTED]> wrote:
> You should explain HOW do you worked around hiding the option in IE.
> What do you need to do exactly?
> I had the opposite problem some time ago, I was all cursing Firefox,
> for not respecting the selected="selected" on refreshes.
> You could force the selectedIndex to 0 (or something else) on start,
> or use a cookie to remember the last selected option and force it to
> be the selected one.
> If this is not enough.. then explain a bit what do you want IE to
> do..
>
> Ariel Flesler
>
> On 14 nov, 12:56, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > Anyone?  I could really use some insight into this problem.

Reply via email to