View Full Version : Adding to SELECT works in NS6 but not IE6

10-12-2002, 12:47 AM
I'm coding a javascript listpair where you select entries in one list,
click the arrow, and the items are moved from the source list to the target list. I use the 'name' field to locate the SELECT list.
In NS6, the following code works fine. In IE6, it fails
near the line marked. Does anyone have an idea why?
Where can I find the DOM properites and functions for IE?
I've been using the W3C references, but clearly IE must
be doing something different (as usual).

function moveListSelection(src, tgt)
source = document.getElementsByName(src)[0] ;
if (source == null) return ;

target = document.getElementsByName(tgt)[0] ;
if (target == null) return ;
* Move all selected options in source to the target
* note that if we start from 0, the remove will
* reorder subsequent items, so we start from the
* end of the source list.
tgtBefore = null ;
for (i=source.length-1; i>=0; i--)
option = source.options.item(i) ;
if (option.selected)
source.remove(i) ;
target.add(option, tgtBefore) ; // **IE quits here!! why?
tgtBefore = option ; // add next item before this one

10-14-2002, 08:39 AM
The add method in IE takes a number as a second parameter. So change

target.add(option, tgtBefore);


target.add(option, 0);

10-14-2002, 04:04 PM
That did it! Thanx muchly (Thank you very much)

01-08-2009, 10:20 PM
I write this code:
function addToGroup(){
groupSelected = document.getElementById('idslibresG');
groupsusers = document.getElementById('idsgrupoUSG');
indiceGS = groupSelected.selectedIndex;
groupsusers.options[0] = null;//borro el elemento vacio
groupSelected.options[0] = null;//borro el elemento vacio
groupsusers.add(groupSelected.options[indiceGS],null); // standards compliant
groupsusers.add(groupSelected.options[indiceGS]); // IE only:mad: X(


the line with the face, it gets an error in IE6, says
argument not valid, cod. 0

01-11-2009, 06:52 AM