Closed Bug 203751 Opened 21 years ago Closed 20 years ago
Attribute('selected', 'selected') on an option element does not give an option element with attribute&value pair selected="selected"
Brian, Can you attach a simplified testcase showing the problem?
* The snippet below, I pasted in from a larger piece of code (hence the nodeOption vs nodeOption1 .. ugh, sorry) * here's the simplest testcase : <a href="http://test.lophty.com/mozilla_testcases/test_setAttribute_selected_selected.htm">http://test.lophty.com/mozilla_testcases/test_setAttribute_selected_selected.htm</a>
I think I'm having a similar problem. Browser: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Text Editor: Dreamweaver Ultra Dev. I've got code that creates a dropdown box. The resulting HTML looks like this: <select NAME='level'> <option value = 1> Primary</option> <option value = 2> Primary/Intermediate</option> <option selected value = 3> Intermediate</option> <option value = 4> Intermediate/Adolescent</option> <option value = 5> Adolescent</option> </select> However, it doesn't display option number 3 as selected. It does render correctly using IE. I'm willing to be told that I'm doing something stupidly wrong. :) Thanks!
Sorry for being late in responding.. here are my thoughts on this "bug": getAttribute("selected") for an option element returns an empty string. This is because StringToAttribute for option elements gives an empty value to the selected and disabled attributes. This should be changed imho (unless it's for backwards compat reasons). So setAttribute works fine but in fact getAttribute doesn't return the correct string. There is another problem to StringToAttribute as it stands: selected="false" doesn't work. (jst?) To summarize, everything works apart from getAttribute because of StringToAttribute in nsHTMLOptionElement.cpp Confirming marking NEW. Puzzling for web devs so setting P3, tm future BTW, is it just me or does .label not work in Mozilla? (for option elements)
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Linux → All
Priority: -- → P3
Target Milestone: --- → Future
I rewrote my test case from scratch and now it works fine. I also see that this bug was for setting not getting this property, so my comment was misplaced in any case. Please disregard my previous comment, and accept my apologies. Feel free to delete it if desired.
sorry, i was rash, i tested on an old Mozilla, it's working on 1.6a...
Fixed by the checkin for bug 232706
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.