Bug Tracker

Opened 11 years ago

Closed 11 years ago

#10116 closed bug (invalid)

Get the selected value of matched select in IE6

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:


I didn't find any bugs matching this.

Immediately after populating my drop down via

for (var i = 0; i < options.length; i++) {
   $("#" + mStateDDToUpdate).append("<option value='" + options[i].Key.trim() + "' >" + options[i].Value.trim() + "</option>");                

I select the desired option from the list

try {
   if (typeof StateToSelect != 'undefined' && StateToSelect != null) {
       $("#" + mStateDDToUpdate).val(StateToSelect);
} catch (ex) {
   alert("Error setting the list.\r\n" + ex.message);

The ex.message that was caught was "Could not set the selected property. Unspecified error." The selector does find the object, and the value is in the options. It seems to be a timing thing, because if I add an alert before setting the selected option then there is no exception. I only got this exception when I tested in IE 6.0.3790.3959, not in IE 8.0.6001.18702 or Chrome 13.0.782.112.

I did my best to recreate the whole thing in jsFiddle here: http://jsfiddle.net/r3g9g/ however, as I mentioned I only see the bug in IE6. Also, I know I don't have all the US states in the list that is not an error.

Change History (1)

comment:1 Changed 11 years ago by dmethvin

Resolution: invalid
Status: newclosed

IE6 can be picky when it comes to populating select boxes. Inserting options one at at time is a bad idea for performance reasons. Instead, create a new select not in the document and append that to the doc after inserting all the options. Or create that entire select+options as a string and put it in the document as html.

It's probably best to continue this discussion at http://forum.jquery.com since it's not something jQuery can or will fix a decade after IE6 has shipped.

Note: See TracTickets for help on using tickets.