I too was having this problem.
I have used JavaScript to add a new option to a parent's select box many times with ColdFusion, Java servlets, and static HTML without any problems. For some reason, this ASP project was causing this error. I tried many versions of this code and it only happens in IE (I am using 5.0)
My original code was:
//create reference to parent form's select box
s = opener.document.myForm.selectBox;
//add new option
s.options[ s.options.length ] = new Option( "name", "id" );
//make the new option the currently selected option
s.selectedIndex = s.options.length - 1;
I also tried this for IE specifically:
//create option object
sel = document.createElement( "OPTION" );
//assign text property
sel.text = "name";
//assign value property
sel.value = "id";
//add the option to the parent form's select box
self.opener.document.myForm.selectBox.add( sel );
This also did not work. I finally got it to work by using a technique much like Todd's. I think this is a little more elegant:
In the parent page, I added the following function:
function addOption( name, id ) {
//create reference to select box
var sel = document.myForm.selectBox;
//add new option to the end of the select box's options array
sel.options[ sel.options.length ] = new Option( name, id );
//make the new option the currently selected option
sel.selectedIndex = sel.options.length - 1;
}
In the child I called the function:
self.opener.addOption( 'name', 'id' );
In my application I used a dynamic way of setting the text and value properties but this code should fix this odd IE bug. I hope this helps someone.
Eric T