little question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin Auch

    little question

    Hi,

    I want to know if it's possible from a popup to add Option on a Select
    object on the parent, by just calling the Select object like this :

    var openerForm = window.top.open er.document.for ms[0];
    opt = new Option(theLabel , theValue,false, false);
    openerForm.mySe lect.options[i] = opt;

    Or maybe I must use another way by passing the option like a string on an
    hidden field an evaluate this string ?

    Thanks for your help

    Kevin


    //--------------------------------------------------
    Kevin Auch
    MVP .NET
    CodeWise Community Member

    ----------------------------------------------------//


  • Richard Cornford

    #2
    Re: little question

    Kevin Auch wrote:[color=blue]
    > I want to know if it's possible from a popup to add Option
    > on a Select object on the parent, by just calling the Select
    > object like this :
    >
    > var openerForm = window.top.open er.document.for ms[0];
    > opt = new Option(theLabel , theValue,false, false);
    > openerForm.mySe lect.options[i] = opt;[/color]

    No it is not.
    [color=blue]
    > Or maybe I must use another way by passing the option like a
    > string on an hidden field an evaluate this string ?[/color]

    It is generally the rule in javascript that anything that proposes using
    the - eval - function is the worst approach available.

    The problem is (ultimately) the location in which the memory that your
    new Option uses resided. If you use - new Option( ... ) - the new option
    element is created in the window/frame in which the - Option -
    constructor being used is located. Attempting to add that option to an
    element of a form in another window/frame will not work.

    Usually the simplest solution is to create a function in the
    frame/window in which the form resides that will take (string and/or
    number) arguments and locally create a new Option and insert it in the
    form, calling that function from the separate frame/window.
    [color=blue]
    > //--------------------------------------------------[/color]

    If you are going to post to Usenet you should use the specified standard
    signature separator.
    [color=blue]
    > Kevin Auch
    > MVP .NET[/color]

    MVP?

    Richard.


    Comment

    Working...