Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    adding options in select widget not working in internet explorer

    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.

    Code:
    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

    Code:
    selectWidget[length] = new Option( name, label, false, false );
    Is there anything wrong with this statement ??
    Last edited by rameshg87; 04-24-2010 at 06:54 AM. Reason: adding more information

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,518
    Thanks
    3
    Thanked 506 Times in 493 Posts
    Code:
    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 );
        }
    }
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 ??

  • #4
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,518
    Thanks
    3
    Thanked 506 Times in 493 Posts
    please post a link to your page
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •