get a value from a popUp window

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

    #1

    get a value from a popUp window

    Hi, I'm using the folowing javascript code to oprn a popUp window
    msgWindow=windo w.open('','mess ageWindow', 'scrollbars=yes ,width=300,
    height=150');
    msgWindow.docum ent.open();
    msgWindow.docum ent.write(strHT ML);
    msgWindow.docum ent.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.



  • Michael Winter

    #2
    Re: get a value from a popUp window

    On Wed, 3 Mar 2004 16:42:27 -0500, toufik toufik <toufiki@sympat ico.ca>
    wrote:
    [color=blue]
    > Hi, I'm using the folowing javascript code to oprn a popUp window
    > msgWindow=windo w.open('','mess ageWindow', 'scrollbars=yes ,width=300,
    > height=150');[/color]

    [snip]
    [color=blue]
    > 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.[/color]

    "messageWin dow" is the name of the window with regard to target
    attributes. That is, target="message Window" 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,res izable,width=30 0,height=150');

    Then:

    msgWindow.docum ent.forms[0].TXTNAME.value

    to reference the value.

    Mike

    --
    Michael Winter
    M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

    Comment

    • toufik toufik

      #3
      Re: get a value from a popUp window

      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" <M.Winter@bluey onder.co.invali d> wrote in message
      news:opr4a38jsx 5vklcq@news-text.blueyonder .co.uk...[color=blue]
      > On Wed, 3 Mar 2004 16:42:27 -0500, toufik toufik <toufiki@sympat ico.ca>
      > wrote:
      >[color=green]
      > > Hi, I'm using the folowing javascript code to oprn a popUp window
      > > msgWindow=windo w.open('','mess ageWindow', 'scrollbars=yes ,width=300,
      > > height=150');[/color]
      >
      > [snip]
      >[color=green]
      > > 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.[/color]
      >
      > "messageWin dow" is the name of the window with regard to target
      > attributes. That is, target="message Window" 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,res izable,width=30 0,height=150');
      >
      > Then:
      >
      > msgWindow.docum ent.forms[0].TXTNAME.value
      >
      > to reference the value.
      >
      > Mike
      >
      > --
      > Michael Winter
      > M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)[/color]


      Comment

      • Michael Winter

        #4
        Re: get a value from a popUp window

        On Wed, 3 Mar 2004 17:50:25 -0500, toufik toufik <toufiki@sympat ico.ca>
        wrote:
        [color=blue]
        > But it doesn't work, I find that it works with this syntax
        > window.document .forms[0].TXTNAME .value[/color]

        [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
        M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

        Comment

        Working...