get a value from a popUp window

Discussion in 'Javascript' started by toufik toufik, Mar 3, 2004.

  1. Hi, I'm using the folowing javascript code to oprn a popUp window
    msgWindow=window.open('','messageWindow', 'scrollbars=yes,width=300,
    height=150');
    msgWindow.document.open();
    msgWindow.document.write(strHTML);
    msgWindow.document.close();

    In this window I've a form containing a text TXTNAME and a button that call
    another function javascript popUpProcess()

    How can I get the value of TXTNAME inside the function popUpProcess()?
    I've tried message"Window.forms[0].TXTNAME .value" but it doesn't work.

    Thanks.
    toufik toufik, Mar 3, 2004
    #1
    1. Advertising

  2. On Wed, 3 Mar 2004 16:42:27 -0500, toufik toufik <>
    wrote:

    > Hi, I'm using the folowing javascript code to oprn a popUp window
    > msgWindow=window.open('','messageWindow', 'scrollbars=yes,width=300,
    > height=150');


    [snip]

    > How can I get the value of TXTNAME inside the function popUpProcess()?
    > I've tried message"Window.forms[0].TXTNAME .value" but it doesn't work.


    "messageWindow" is the name of the window with regard to target
    attributes. That is, target="messageWindow" on a link will open the page
    in the popup window. msgWindow is what you want to use: it contains a
    reference to the new window.

    If you must use a popup window, you should allow users to resize it:

    msgWindow = window.open('','messageWindow',
    'scrollbars,resizable,width=300,height=150');

    Then:

    msgWindow.document.forms[0].TXTNAME.value

    to reference the value.

    Mike

    --
    Michael Winter
    d (replace ".invalid" with ".uk" to reply)
    Michael Winter, Mar 3, 2004
    #2
    1. Advertising

  3. Thanks Mike,
    But it doesn't work, I find that it works with this syntax
    window.document.forms[0].TXTNAME .value

    Now I can access the inputs of the original page

    here is my case:
    I've a page that contains a button, in the ONCLIC event I open the popUp
    window, in the onClic event of the popup window I call a javascript function
    where I assign the value entred in the popup to a text in the original page.

    Thanks


    "Michael Winter" <> wrote in message
    news:eek:...
    > On Wed, 3 Mar 2004 16:42:27 -0500, toufik toufik <>
    > wrote:
    >
    > > Hi, I'm using the folowing javascript code to oprn a popUp window
    > > msgWindow=window.open('','messageWindow', 'scrollbars=yes,width=300,
    > > height=150');

    >
    > [snip]
    >
    > > How can I get the value of TXTNAME inside the function popUpProcess()?
    > > I've tried message"Window.forms[0].TXTNAME .value" but it doesn't work.

    >
    > "messageWindow" is the name of the window with regard to target
    > attributes. That is, target="messageWindow" on a link will open the page
    > in the popup window. msgWindow is what you want to use: it contains a
    > reference to the new window.
    >
    > If you must use a popup window, you should allow users to resize it:
    >
    > msgWindow = window.open('','messageWindow',
    > 'scrollbars,resizable,width=300,height=150');
    >
    > Then:
    >
    > msgWindow.document.forms[0].TXTNAME.value
    >
    > to reference the value.
    >
    > Mike
    >
    > --
    > Michael Winter
    > d (replace ".invalid" with ".uk" to reply)
    toufik toufik, Mar 3, 2004
    #3
  4. On Wed, 3 Mar 2004 17:50:25 -0500, toufik toufik <>
    wrote:

    > But it doesn't work, I find that it works with this syntax
    > window.document.forms[0].TXTNAME .value


    [snip]

    I assumed that you were trying to access the control, TXTNAME, that is in
    the popup window from the opener window. In that case, you would need to
    reference the popup like I demonstrated. As you're accessing the control
    from within the same window, the expression below is sufficient.

    document.forms[0].TXTNAME.value

    My mistake.

    Mike


    Please don't top-post.

    --
    Michael Winter
    d (replace ".invalid" with ".uk" to reply)
    Michael Winter, Mar 3, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jack
    Replies:
    4
    Views:
    2,028
  2. Harsha
    Replies:
    0
    Views:
    630
    Harsha
    Nov 5, 2009
  3. Tony Farrell
    Replies:
    1
    Views:
    214
    Randy Webb
    May 10, 2004
  4. Jens Peter Hansen
    Replies:
    7
    Views:
    500
    Randy Webb
    Jun 19, 2004
  5. Raffi
    Replies:
    4
    Views:
    203
    Dr John Stockton
    Aug 12, 2004
Loading...

Share This Page