I spent a few hours yesterday and today working on a small AJAX page with multiple combo boxes that are populated from the database. I use Firefox 99% of the time and I utilize the excellent YUI library for cross-browser compability. I almost done with the page (I’m pretty proud of it too) so I decided to show it to my work buddy. On IE (both 6 and 7), my beatiful double combo boxes just failed miserably. A part of what I was doing was to populate a double combo box with dynamic data from the database. I created an empty SELECT tag (dynamically via JS), assigned its an ID, made an AJAX request, then populated the empty SELECT tag via the innerHTML with the AJAX response, which is a list of OPTION elements. On Firefox, the double combo works so well that I thought it was time wrap up the project. However, on IE, the combo box just mysteriously failed to get populated.
First of all, I tried to eliminiate the possibility of my AJAX requests got messed up somewhere. I traced through the flow of the functions and put alert() to assert the responses of the AJAX requests as I was afraid that the IE 7 I was using to test the page is not compatible with the YUI’s Connection Manager. This was also the first time I ran IE7 after deciding to install it the other day. IE7’s AJAX feature turned out to work just fine, however, after several checkpoints using alert(), I finally discovered a bug in how IE handle the innerHTML property of select item: If the select item’s innerHTML propety is set programmatically, IE will truncate the first opening option tag.
In my case, what I got back from the AJAX request was a list of OPTION elements. When I do the assignment to the innerHTML of the empty SELECT element, the OPTION list’s HTML code got truncated, specfically the first opening OPTION tag. Hence, the html code I used to populate the select list was malformed. And thanks to IE’s impotency, I could not see the generated HTML code of the page (which in Firefox, the Web Developer toolbar works nicely) so I could not even debug HTML source.
I did some Google lookups on IE select element’s innerHTML bug and found out that it is a confirmed bug by Microsoft, moreover, it’s been confirmed since IE 5 (Microsoft’s link). That was so 1999 and yet the bug still lives on until now with IE7. Humh, I totally understand that fixing bugs is being taken care seriously at Microsoft. But the innerHTML bug should be trivial to fix (no security risks that I can think of) and it’s been there for years without anyone from Microsoft bothering to do anything. It’s just ridiculous.
Oh there’s more, the Microsoft Bug page (the above link) shows that the bug report is at revision 2.0. Yeah, I thought “bug 1.0″ is more than enough but apparently I’m wrong because it’s Microsoft.
-1 to microsoft for the slowness of *TRIVIAL* bugs fixing.
-1 to micrsoft for the lack of developer’s handytools. Study Firefox and how the community are doing it, please. (I do aware of the Developers Toolbar for IE, but it is not nearly as useful as the Firefox Web Developers Toolbar)
Thanks. This explained a bug I have been trying to work on for a couple of days.
I am using prototype to have a series of comboboxes tied together. One selects a country, next the region, next the city. It works like a charm in mozilla, but ie, no dice, unless I wrap the combo’s under divs. Now I have to figure how to destroy elements in mozilla so then prototype does not end nesting innerhtmls.
I am new on this stuff, but it has been an uphill battle with these Redmond dudes….
Regards