Problems with referencing javascript windows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Randell D.

    #1

    Problems with referencing javascript windows


    Folks,

    I have a javascript function which is a popup - It contains a list in
    form tags - When the user selects a value in the popup, and clicks
    submit, I want the values to be transfered to the parent opening window.

    I have managed this when I know the name of the parent window - however
    there are two or three different 'parent' forms with different form
    names that could reference this popup session meaning my current
    solution only works for one, but not the others.

    My question therefore is, how, without knowing the parent window name,
    can I write a value to a form input tag field.

    I'm a newbie - part of me thinks I could pass my window name using the
    special 'this' reference - but I'm not quite sure - Can someone help
    direct me in the right direction?

    Cheers
    Randell D.
  • John Doe

    #2
    Re: Problems with referencing javascript windows

    window.opener

    In article <mF2Kd.186761$6 l.69943@pd7tw2n o>,
    reply.via.news. group.only.than ks@fiprojects.m oc says...[color=blue]
    >
    > Folks,
    >
    > I have a javascript function which is a popup - It contains a list in
    > form tags - When the user selects a value in the popup, and clicks
    > submit, I want the values to be transfered to the parent opening window.
    >
    > I have managed this when I know the name of the parent window - however
    > there are two or three different 'parent' forms with different form
    > names that could reference this popup session meaning my current
    > solution only works for one, but not the others.
    >
    > My question therefore is, how, without knowing the parent window name,
    > can I write a value to a form input tag field.
    >
    > I'm a newbie - part of me thinks I could pass my window name using the
    > special 'this' reference - but I'm not quite sure - Can someone help
    > direct me in the right direction?
    >
    > Cheers
    > Randell D.
    >[/color]

    Comment

    • Dietmar Meier

      #3
      Re: Problems with referencing javascript windows

      Randell D. wrote:
      [color=blue]
      > When the user selects a value in the popup, and clicks
      > submit, I want the values to be transfered to the parent opening
      > window.[/color]

      Here is a working example:


      ciao, dhgm

      Comment

      • Lee

        #4
        Re: Problems with referencing javascript windows

        Randell D. said:[color=blue]
        >
        >
        >Folks,
        >
        >I have a javascript function which is a popup - It contains a list in
        >form tags - When the user selects a value in the popup, and clicks
        >submit, I want the values to be transfered to the parent opening window.
        >
        >I have managed this when I know the name of the parent window - however
        >there are two or three different 'parent' forms with different form
        >names that could reference this popup session meaning my current
        >solution only works for one, but not the others.
        >
        >My question therefore is, how, without knowing the parent window name,
        >can I write a value to a form input tag field.
        >
        >I'm a newbie - part of me thinks I could pass my window name using the
        >special 'this' reference - but I'm not quite sure - Can someone help
        >direct me in the right direction?[/color]

        A reference to the window that opened the current window is
        found as window.opener.

        window.opener.d ocument.forms[0].elements["startDate"].value= ...

        Comment

        • Randell D.

          #5
          Re: Problems with referencing javascript windows

          Randell D. wrote:
          [color=blue]
          >
          > Folks,
          >
          > I have a javascript function which is a popup - It contains a list in
          > form tags - When the user selects a value in the popup, and clicks
          > submit, I want the values to be transfered to the parent opening window.
          >
          > I have managed this when I know the name of the parent window - however
          > there are two or three different 'parent' forms with different form
          > names that could reference this popup session meaning my current
          > solution only works for one, but not the others.
          >
          > My question therefore is, how, without knowing the parent window name,
          > can I write a value to a form input tag field.
          >
          > I'm a newbie - part of me thinks I could pass my window name using the
          > special 'this' reference - but I'm not quite sure - Can someone help
          > direct me in the right direction?
          >
          > Cheers
          > Randell D.[/color]

          I got it... I just needed some rough direction because objects and DOM's
          and whatever seem to go,for the most part, over my head - However, if
          someone else is curious on the solution, here goes...

          In my parent window, a new popup window is opened, and named, using
          window.open()

          In my new (child) window, I found I could reference or change the value
          in an INPUT tag in the parent calling window using the following
          declaration:

          window.opener.d ocument.forms[0].myParentInputT agName.value="w hatever";

          Thus, using the above bit of javascript - when contained in my child
          window would lead my parent form, which would contain an <INPUT
          NAME="myParentI nputTagName"> to have the value "whatever" assigned to it.

          randell d.


          Comment

          Working...