new Option and parent window problem with IE

F

Flyzone

I'm trying to add an option to a select from a new window opened as
popup.
From the children window i use:
i =
window.opener.parent.document.getElementById('opt_name').options.length;
window.opener.parent.document.getElemenyById('opt_name').options=new
Option('AAAA','AAAA');

and in the parent window i have declared the select as:
<select name="opt_name[]" id="opt_name" multiple="multiple" size="10">

It works perfectly on FF, on IE 7 i get the error:
"Object doesn't support this property or method".

The strange is that calling the function from the same page works, but
on the children is not passed,
i could just change the value/name using the .value or .innerHTML, but
not adding a new option.

Someone could help me? Thanks in advance.
 
S

SAM

Flyzone a écrit :
I'm trying to add an option to a select from a new window opened as
popup.
From the children window i use:
i =
window.opener.parent.document.getElementById('opt_name').options.length;
window.opener.parent.document.getElemenyById('opt_name').options=new
Option('AAAA','AAAA');

and in the parent window i have declared the select as:
<select name="opt_name[]" id="opt_name" multiple="multiple" size="10">

It works perfectly on FF, on IE 7 i get the error:
"Object doesn't support this property or method".


Probably a kind of protection ?

try :

var selct = opener.document.getElementById('opt_name');
var i = selct.options.length;
var o = new Option('AAAA','AAAA');
selct.options = o;


If that doesn't work try using a function in the opener :

functionAddOption(selectId, text, value) {
var selct = document.getElementById(selectId);
var i = selct.options.length;
var o = new Option(text,value);
selct.options = o;
}

opener.functionAddOption('opt_name', 'AAA', 'AAA');
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top