Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

new option in a <select multiple> but not in the same window

Status
Not open for further replies.

TheBestOfMe

Programmer
Apr 7, 2002
21
CA
I open a pop-up window and I take a <select multiple> values and move them to another <select multiple> but the window that called my pop-up.

the code works well under Netscape, but freeze my Explorer6.

I use the same code as if I was moving my values between two <select> in the same window, but the TO is a reference to the <select> in the opener window.


Here's the code

function SendValue()
{
var to = window.opener.document.form.list;

var from = document.form.list;

selectAllOptions(from);

moveSelectedOptions(from,to);
}

function moveSelectedOptions(from,to)
{
// Move them over
for (var i=0; i<from.options.length; i++)
{
var o = from.options;
if (o.selected)
{
to.options[to.options.length] = new Option( o.text, o.value, false, false);
}
}

// Delete them from original
for (var i=(from.options.length-1); i>=0; i--)
{
var o = from.options;
if (o.selected)
{
from.options = null;
}
}

from.selectedIndex = -1;
to.selectedIndex = -1;
}

function moveAllOptions(from,to)
{
selectAllOptions(from);

moveSelectedOptions(from,to);

}

function selectAllOptions(obj)
{
for (var i=0; i<obj.options.length; i++)
{
obj.options.selected = true;
}
}


The code to move <select> values works well under IE and Netscape if the two <select> are in the same window.

This is the last compatibility problem living in my site and I want to kill it.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top