Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript : Opening handeling textbox in popup window

    Hi there

    I want to controle the value of a text field in a popup window.

    the window is opened by the code:
    Code:
    win = window.open(url.asp)
    This new window contains a form with an textbox in it.

    Now how can I access this textfield in the code of the parent window??

    Thanx in advance

    Grtz
    Terrorke

  • #2
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    win.document.form_name.element_name.value ...

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Terrorke
    I want to controle the value of a text field in a popup window.

    this new window contains a form with an textbox in it.

    Now how can I access this textfield in the code of the parent window??
    you've confused me: which window do you wanna control - the popup (child) or opener (parent)?
    *keep it simple (TM)

  • #4
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jbot
    you've confused me: which window do you wanna control - the popup (child) or opener (parent)?
    oh.. mm I 'm too tired, I probably misintrepted then.. *head explodes*

    if you're going from the popup to the parent window
    opener.document.form_name.element_name.value ..

  • #5
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I whant to controle the child via the parent.

    So let' say :

    in the child window (the popup) there is a text field called Username.

    How can I set its value in the parent after I open the new window?

    Grtz

    Terrorke

  • #6
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Terrorke
    I whant to controle the child via the parent.

    So let' say :

    in the child window (the popup) there is a text field called Username.

    How can I set its value in the parent after I open the new window?

    Grtz

    Terrorke
    Code:
    window.opener.document.form_name.element_name.value

  • #7
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by fci
    Code:
    window.opener.document.form_name.element_name.value
    I have tried to do that but than I always get an error like

    "Win.document.form1.username is not an object"

    Maybe I wasn't so clear. I want to control an element in the child form the parent. And not the way around.

    Grtz
    Terrorke

  • #8
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Terrorke
    I have tried to do that but than I always get an error like

    "Win.document.form1.username is not an object"

    Maybe I wasn't so clear. I want to control an element in the child form the parent. And not the way around.
    well, then this should work so long as it's in the opener:

    <a href="#" onclick="if (win && !win.closed) win.document.form1.username.value='whatever'"; return false">change value</a>

    JS is case sensitive!!
    *keep it simple (TM)

  • #9
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It didn't work yet, but I will carry on my quest.

    If I find a solution, I will post it here.

    Thanx anywayz for your time and suggestions.

    Grtz
    Terrorke

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You say that the popup window is opened with this code:

    win = window.open(url.asp)

    Understand then that the variable "win" returned from the window.open function is an object reference to the "window' object of the newly opened popup window. However, the snippet of code you gave above doesn't tell the whole story because of this commonly performed mistake:

    Code:
    function ABadWayToOpenAPopup(newURL)
        {
        var win;
        win = window.open(newURL);
        }
    If the variable "win" is declared within the function then there's no way you can reference the returned object outside of that function. The "win" variable should be a global object or attached as a property of a global object so that it can be used later. If your "win" object isn't declared global then it's possible that's why you can't get the suggestions provided here to work.
    Check out the Forum Search. It's the short path to getting great results from this forum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •