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 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Submit form to opener window from a popup window

    Is it possible to submit a form from a popup window to the opener window?
    Here is what I'm trying to do:
    I have opened a popup window from my main window.
    I have a form in the popup window.
    I want to submit the form to the main window and close the popup window. Help me!

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    Western US
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do you just want to pass the values from the pop-up to the main window? Or do you really want to post it to another page in the parent window?

    You can set values in the opener from the child by referencing the "opener" window. You could set the value into a filed on the opener or in a variable in a javascript to be used by the opener. Reference it from the child like you would if it was on that page but use opener.

    opener.dcoument.formName.FormField.value = docuemnt.childForm.childField.value

    An example of this can be seen in this thread.
    http://www.codingforums.com/showthre...&threadid=1859

    ShriekForth

  • #3
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the quick response.
    I really want to post it to another page in the parent window?
    Is this possible?

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use this
    Code:
    <html>
    <head>
    <script>
    function setTarget(Frm)
    	{
    	Frm.target = top.opener.location.href;
    	return true;
    	}
    </script>
    </head>
    <body>
    <form onSubmit="return setTarget(this)" method="post" action="whatever.php" target="">
    {....HTML....}
    </form>
    </body>
    </html>
    Last edited by beetle; 08-05-2002 at 09:43 PM.

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    Can a target be an object reference?

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry, I edited it a bit after posting...should be accurate now...(in other words, NO, not that I know of)

  • #7
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have tried that but it submitting to a new window.

    Here is an alternative to this problem:

    In the parent window page:
    Create hidden fields to hold popup form fields.

    In popup window page:
    Move all the form field values to the opener form hidden fields.
    Set the action of opener.
    Submit the opener form.
    Close the popup window.

    Any other solutions?
    Thanks for the help.

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    verelly...

    In the pop-up:

    <form action="some_url" target="mainWin">

    In the main (opener) window:

    <script type="text/javascript" language="javascript">

    self.name = 'mainWin';

    </script>

    In the file referenced as "some_url" above:

    <script type="text/javascript" language="javascript">

    var child = open('',name);
    if (child && !child.closed) child.close();

    </script>

    Use the name you opened the pop-up with in place of name, in quotes. Might work...

  • #9
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks...
    That works...


  •  

    Posting Permissions

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