IE7 Still Has Problems With Option Tag Values
Published October 23rd, 2006 in Software, Web PagesA while back I posted about how IE6 and the beta versions of IE7 had problems with option tags. According to W3 standards, if no value attribute is specified, then the browser should use the text value (i.e., the value between the opening and closing option tags).
For instance, if you use this javascript:
[js]function testFunction() {
var test = document.getElementById(”test”).value
document.getElementById(”results”).innerHTML=test;
return false;
}[/js]
With this HTML:
[html]
[/html]
Then you should see the words “IE SUCKS,” if you return the first option and “This should return this exact sentence, NOT BLANK,” if you return the second option. IE6 and the beta versions of IE7 would return the first value correctly, but would return a blank for the second option. Since this is incorrect, I submitted the bug to the IE7 development team and received a generic “thanks for telling us how much our browser sucks, we will pretend to look into this issue” reply.
Since this would really only be a few lines of code (and the IE7 crew claimed compliance was an important issue), I figured this would be solved by the time IE7 was released. Ha, ha, ha… silly me! Since the issue was not resolved, I thought I should visit the feedback site to see if they had posted anything else about the bug I submitted.
Thank you for participating in the IE7 Beta Program. We appreciate the feedback you provided.
Now that the final version of IE7 has been released, the IE Feedback site is temporarily closed. It will re-open in the future.
The issues that were active or closed as “By Design”, “Won’t fix”, or “Postponed” will be considered for future releases of IE.
If you experience any problems with IE7, you can get help by visiting the Internet Explorer 7 Support Page.
Thanks,
Internet Explorer Team.
(Note: I added the bolded words, so their “team” would not look as stupid.) I guess for IE8 they will consider making it HTML 4 compliant… For those of you seeking a workaround (did you really think IE7 would be the end of IE-specific workarounds?), you have to grab the text value with this:
[js]document.getElementById(”test”).options[document.getElementById(”test”).selectedIndex].text[/js]
Unfortunately, using that code means you will not use whatever the value attribute is set to. One option is to use an if statement to check the value first, and if that’s null, check the text with the above code. Of course then you have to consider what to do with different return values across browsers. If there is a difference, I suggest a link to download Firefox.


I find it really hard to believe they made such a glaring omission from their browser. And no, not even IE7. I’m surprised this type of bug slipped into IE6. I’ve always taken for granted that you could leave the value attribute off if you wanted to, but then again I haven’t used that technique in a long time (I think). That’s the only explanation I can think of for why I wouldn’t have noticed this, because I use the option tag quite frequently when developing form-based web pages.
I guess the only silver lining is that there is a standards-based workaround to the problem.