SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    England
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form opening in the main window/ simeltaneiously closes popup window

    I have a popup window which has the search form in. What I want to do is for the popup window to close once the form is submitted, and to post the form data to a page on the main window.

    Is anyone able to advise. As the main page is dynamic, it is not possible to give the page a name.

    Cheers

    K

  2. #2
    SitePoint Guru JoePrice's Avatar
    Join Date
    Jan 2002
    Location
    UK
    Posts
    673
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have a look into using the javascript the opener command.

    say a link in a window is used to open a new popup window, within that popup you can use the javascript command opener.close() to close the parent window.

    So i'm guessing you'd probably have to use some javascript with opener in it

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not nearly enough information. Could you post some code?
    ::: certified wild guess :::

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    England
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by adios
    Not nearly enough information. Could you post some code?

    Well the code in the popup window has the form. I want the form values to be passed to another page in the main browser window and simeltaneously close the popup window.

    The form is

    Code:
    <FORM name=form action=http://webaddress/scripts/search.exe method=post>
    <SPAN class=feedtext>What are you looking for?</SPAN> <br>
    		<INPUT size=15  name=QUERY00> <INPUT type=image height=15 hspace=3 width=36 
          src="search.gif" value=Search border=0 
          name=CMD=search.run> 
    <INPUT type=hidden value=AMA_dlist_d name=SAVEDB> </FORM>

  5. #5
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still unclear. You said you wanted 'the form values to be passed to another page in the main browser window' - but you have both an action & a method assigned to the pop-up form. If you're only using that form as a GUI widget within your site, it won't be submitting to the server.

    <FORM name="popform" onsubmit="return setOpenerForm(this)">
    Code:
    <script type="text/javascript">
    
    function setOpenerForm(oForm)
    {
    	if (opener && !opener.closed)
    	{
    		if (opener.document.mainform)
    		{
    			opener.document.mainform.somefield.value = oForm.somefield.value;
    			opener.document.mainform.some_other_field.value = oForm.some_other_field.value;
    		}
    	}
    	self.close();
    	return false;
    }
    
    </script>
    Just substitute the name of the 'main' form (red), and the names of the fields being transferred from (blue) and to (green).
    ::: certified wild guess :::


Bookmarks

Posting Permissions

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