...

View Full Version : adding options in select widget not working in internet explorer



rameshg87
04-24-2010, 07:53 AM
Hi All,

I have a javascript function which adds a label and value to a select widget in its parent window. The function is working fine in firefox and chrome without any errors or warnings. But it is not working in internet explorer. Please tell me what the issue is. Thanks in advance for your help.



function addToParent( formName, selectName, name, label ) {

var parent = window.opener;
var selectWidget = parent.document.forms[formName].elements[selectName];

if( selectWidget ) {

var length = selectWidget.length;
selectWidget[length] = new Option( name, label, false, false );
}
}


When I tried to debug, internet explorer shows an error in the following line



selectWidget[length] = new Option( name, label, false, false );


Is there anything wrong with this statement ??

vwphillips
04-24-2010, 10:22 AM
function addToParent( formName, selectName, name, label ) {

var parent = window.opener;
var selectWidget = parent.document.forms[formName].elements[selectName];

if( selectWidget ) {

var length = selectWidget.options.length;
selectWidget.options[length] = new Option( name, label, false, false );
}
}

rameshg87
04-24-2010, 10:47 PM
Hi,

Thanks for your help.

But this code seem to have some problem.

The code execution seem to stop at the same place. IE debugger says the following error message "Object doesn't support this property or method". What could be the problem ??

vwphillips
04-25-2010, 10:29 AM
please post a link to your page



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum