window.opener HELP!!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ctrl+alt+delete

    window.opener HELP!!

    I have a normal window cotaining a form (named form1). The form has a text
    input called imageURL. There is a button that, when clicked, opens a new
    window that contains three frames (left, right and bottom.) In the right
    frame is another form (named form2) with a hidden input (selected). When
    form2 is submitted, I want the value of selected to be passed back to the
    imageURL on form1 and then close.

    The code I have tried is as follows:

    (From my frame...)
    <SCRIPT language="JavaS cript">
    function passValues()
    {
    // pass variable back to parent window
    window.opener.d ocument.form1.i mageURL.value =
    document.form2. selected.value;
    }
    top.window.clos e();
    </SCRIPT>

    It closes just fine, but imageURL on form1 never changes.

    Anyone with ideas on how to make this work is encouraged to offer their
    help!!


  • Dietmar Meier

    #2
    Re: window.opener HELP!!

    ctrl+alt+delete wrote:
    [color=blue]
    > In the right frame is another form (named form2) with a
    > hidden input (selected). When form2 is submitted, I want the value of
    > selected to be passed back to the imageURL on form1 and then close.
    > [...]
    > // pass variable back to parent window
    > window.opener.d ocument.form1.i mageURL.value =
    > document.form2. selected.value;[/color]

    The opener opened the frameset's top window, not the frame your statement
    is in. So you want to use top.opener... instead of window.opener.. . here.
    In addition, since the popup is not modal, you should avoid error
    messages caused by an already closed opener window (or by having another
    document in the opener already) by testing if the used properties and
    objects are still available:

    var oOpener, oOpenerForm, oOpenerElement;
    if (
    (oOpener = top.opener)
    && !oOpener.closed
    && (oOpenerForm = top.opener.docu ment.forms["form1"])
    && (oOpenerElement = oOpenerForm.ele ments["imageURL"])
    ) {
    oOpenerElement. value
    = document.forms["form2"].elements["selected"].value;
    }

    This looks a little laborious compared to waht you had, but it's
    essential to avoid error messages.

    ciao, dhgm

    Comment

    • ctrl+alt+delete

      #3
      Re: window.opener HELP!!

      Hey, thanks a lot for the quick reply! I will try out what you suggested and
      post my results.

      "Dietmar Meier" <usereplytoinst ead@innoline-systemtechnik.d e> wrote in
      message news:36h5iqF53j naoU1@individua l.net...[color=blue]
      > ctrl+alt+delete wrote:
      >[color=green]
      >> In the right frame is another form (named form2) with a
      >> hidden input (selected). When form2 is submitted, I want the value of
      >> selected to be passed back to the imageURL on form1 and then close.
      >> [...]
      >> // pass variable back to parent window
      >> window.opener.d ocument.form1.i mageURL.value =
      >> document.form2. selected.value;[/color]
      >
      > The opener opened the frameset's top window, not the frame your statement
      > is in. So you want to use top.opener... instead of window.opener.. . here.
      > In addition, since the popup is not modal, you should avoid error
      > messages caused by an already closed opener window (or by having another
      > document in the opener already) by testing if the used properties and
      > objects are still available:
      >
      > var oOpener, oOpenerForm, oOpenerElement;
      > if (
      > (oOpener = top.opener)
      > && !oOpener.closed
      > && (oOpenerForm = top.opener.docu ment.forms["form1"])
      > && (oOpenerElement = oOpenerForm.ele ments["imageURL"])
      > ) {
      > oOpenerElement. value
      > = document.forms["form2"].elements["selected"].value;
      > }
      >
      > This looks a little laborious compared to waht you had, but it's
      > essential to avoid error messages.
      >
      > ciao, dhgm[/color]


      Comment

      • ctrl+alt+delete

        #4
        Re: window.opener HELP!!

        Here's what I ended up going with and it works perfectly:

        top.window.open er.document.for ms["form1"].elements["imageURL"].value =
        "#Form.selected #";

        Note: I am processing this script on a ColdFusion page, hence the use of
        #Form.selected# .

        Thanks again for the help. I wasn't sure how to reference the input back on
        my original page.


        "Dietmar Meier" <usereplytoinst ead@innoline-systemtechnik.d e> wrote in
        message news:36h5iqF53j naoU1@individua l.net...[color=blue]
        > ctrl+alt+delete wrote:
        >[color=green]
        >> In the right frame is another form (named form2) with a
        >> hidden input (selected). When form2 is submitted, I want the value of
        >> selected to be passed back to the imageURL on form1 and then close.
        >> [...]
        >> // pass variable back to parent window
        >> window.opener.d ocument.form1.i mageURL.value =
        >> document.form2. selected.value;[/color]
        >
        > The opener opened the frameset's top window, not the frame your statement
        > is in. So you want to use top.opener... instead of window.opener.. . here.
        > In addition, since the popup is not modal, you should avoid error
        > messages caused by an already closed opener window (or by having another
        > document in the opener already) by testing if the used properties and
        > objects are still available:
        >
        > var oOpener, oOpenerForm, oOpenerElement;
        > if (
        > (oOpener = top.opener)
        > && !oOpener.closed
        > && (oOpenerForm = top.opener.docu ment.forms["form1"])
        > && (oOpenerElement = oOpenerForm.ele ments["imageURL"])
        > ) {
        > oOpenerElement. value
        > = document.forms["form2"].elements["selected"].value;
        > }
        >
        > This looks a little laborious compared to waht you had, but it's
        > essential to avoid error messages.
        >
        > ciao, dhgm[/color]


        Comment

        Working...