Originally Published 2008-01-15 21:25:33
Screw the "HTMLSelectElement object". Whatever that is. ;-) Just append a text child and set the appropriate attribute.
This works in both IE and Firefox:
myOpt = document.createElement('option')myOpt.appendChild(document.createTextNode('hello');myOpt.setAttribute('value', 'hello was the choice');
As for these methods, don't bother. Firefox likes this one:
myOpt.value = 'hello was the choice, too bad IE users cannot see it';myOpt.text = 'hello Firefox users only';
...and Internet Explorer can deal with (this is the #1 Google hit, by the way! Dammit.):
document.forms['testform'].testselect.options[i] = new Option('new text','but Firefox cannot see it!');
While I'm recording notes from hours of browser battles, here's how to get around the limitations (features?) of innerHTML and get to just the text:
...works in both browsers.
If you have only one child object there, of course, if you don't, we'll, you'll just have to actually program. As for the other variations that are not cross-browser compatible:
...works in Firefox. not IE. And
...works in Internet Explorer. Not FF.
On 2008-01-27 01:52:42 Online Bingo said:
22 hours seems pretty long right?
i've been in such a situation, programming for the entire day up to next morning
it's like living in hell
On 2009-02-12 14:35:28 Tk said:
I've gone on 48 hour coding binges. When you're trying to fix something you really can't step away or you'll never fix it.