Skip to main content

Bug Tracker

Side navigation

#10116 closed bug (invalid)

Opened August 22, 2011 10:13PM UTC

Closed August 22, 2011 11:14PM UTC

Get the selected value of matched select in IE6

Reported by: sparebox84@yahoo.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:
Description

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.

Attachments (0)
Change History (1)

Changed August 22, 2011 11:14PM UTC by dmethvin comment:1

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.