Welcome to WebmasterWorld Guest from 23.22.220.37

Forum Moderators: open

Message Too Old, No Replies

IE cuts off first option tag using innerHTML

     
2:52 am on Oct 22, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Sept 4, 2002
posts:508
votes: 0


I'm using a small AJAX function to populate a dropdown list. When the response comes back from the server, it's already formatted in HTML as a series of options - I just stick it in an empty dropdown using innerHTML. This works in Firefox, but in IE, the first option is cut off before the text of the option.

So if the server sends me:
<option value="one">one</option>
<option value="two">two</option>

In IE, I get:
one</option>
<option value="two">two</option>

Does anyone have a solution for this? Thank you so much!

9:18 am on Oct 22, 2006 (gmt 0)

Full Member

10+ Year Member

joined:Jan 23, 2004
posts:338
votes: 0


Are you using an array in your script that accepts your AJAX HTTP Request? I ask because maybe you are looping through the array starting at 1 and should be using 0.
9:19 am on Oct 22, 2006 (gmt 0)

Full Member

10+ Year Member

joined:Jan 23, 2004
posts:338
votes: 0


I am also thinking that maybe your first option should have a value of 0.
9:19 am on Oct 22, 2006 (gmt 0)

Full Member

10+ Year Member

joined:Jan 23, 2004
posts:338
votes: 0


Do you have a URL we can look at?
3:49 am on Oct 27, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Sept 4, 2002
posts:508
votes: 0


Thanks for the responses! I wasn't using an array, but I did end up using one. Turns out this is a known bug in IE. I had to split the response and rebuild the list using the Option object, rather than just using innerHTML to insert the whole thing.