[thelist] [DOM] Dynamically adding an OPTION to SELECT - funky IE vs Gecko...

Andrew Clover and-evolt at doxdesk.com
Tue Mar 16 02:45:45 CST 2004

Tom Dell'Aringa <pixelmech at yahoo.com> wrote:

> The rub is in an OPTIONAL parameter in the add() method[1].

In the DOM Level 1 HTML spec itself:


there is no such parameter (indeed, there are no 'optional' parameters 
in the standard DOM as Java wouldn't be able to support it). Instead 
there is a required second parameter of the adjacent sibling node, so 
the method works the same as appendChild.

IE's implementation of add() is quite incompatible with the the standard 
(and what Mozilla does), so the MSDN note about it being 'defined in DOM 
Level 1' is a bit misleading.

You could try code forking, but it's probably a better idea to use the 
Select object's tried-and-true 'options' collection, or the normal Level 
1 Core method appendChild to populate the field instead.

Andrew Clover
mailto:and at doxdesk.com

More information about the thelist mailing list