wac
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
}
}
}
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
}
}
}