optgroup IE 8-

174 views
Skip to first unread message

kstubs

unread,
Aug 13, 2011, 11:56:48 PM8/13/11
to prototype-s...@googlegroups.com
I am having trouble with optgroup in IE 8 and less.  I am doing something like:

 optgroup = new Element('optgroup');

list_items.each(function(item) {
   optgroup.insert('<option>item.level</option>');
});

They are not appearing.  I read something earlier that Prototype doesn't automatically extend the optgroup element.  Is this the case, is this the problem?

Karl..

Victor

unread,
Aug 15, 2011, 6:27:04 AM8/15/11
to prototype-s...@googlegroups.com
Is your optgroup appearing in select? You can try to create options with
var option = new Option(item.level, item.level);

kstubs

unread,
Aug 15, 2011, 2:35:41 PM8/15/11
to prototype-s...@googlegroups.com
What is Option?  Is this a class/object in the Prototype.js API?

Tom Gregory

unread,
Aug 15, 2011, 8:56:07 PM8/15/11
to Prototype & script.aculo.us
It's a feature in Javascript since Javascript 1.1.
http://docstore.mik.ua/orelly/webprog/webnut/ch11_04.htm#IXT-11-1363

new Option([text [, value [, defaultSelected [, selected]]]])

It's also it W3V specs: http://www.w3.org/TR/2011/WD-html5-author-20110809/the-option-element.html


TAG

kstubs

unread,
Aug 15, 2011, 9:38:01 PM8/15/11
to prototype-s...@googlegroups.com
Dohhh!  Call me a ProtoScripty junky :)  OK but Tom, I'm not sure how that helps my optgroup issue :/

Victor

unread,
Aug 18, 2011, 6:12:45 AM8/18/11
to prototype-s...@googlegroups.com
Sometimes IE refuses to insert options created with new Element() or innerHTML into SELECT or OPTGROUP. Approach with new Option() is more reliable (at least for me) while still cross-browser.
Reply all
Reply to author
Forward
0 new messages