Sending form info from popup window to original window

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

    Sending form info from popup window to original window

    I have a popup window with a form:

    The popup window is opened like this:

    <SCRIPT LANGUAGE=javasc ript>
    window.open('pr imos.html', 'primos', config='height= 300, width=400')
    </SCRIPT>

    The form on the popup window is this:

    <form action="primos. php" method="POST">
    Buscar los primos entre 1 y
    <input type="text" size="7" name="max" value="1000"><b r>
    <input type="submit" name="start" value="Start">
    </form>

    How can I get the form to send the info to "primos.php " and open it in
    the original window?

    Thanks in advance,
    Philippe
  • Lasse Reichstein Nielsen

    #2
    Re: Sending form info from popup window to original window

    person000000000 0@yahoo.com (Person) writes:
    [color=blue]
    > I have a popup window with a form:
    >
    > The popup window is opened like this:
    >
    > <SCRIPT LANGUAGE=javasc ript>[/color]

    The "type" attribute is required. This should be
    <script type="text/javascript">
    [color=blue]
    > window.open('pr imos.html', 'primos', config='height= 300, width=400')[/color]

    The "config=" is not necessary. The config string should not contain spaces,
    some browsers choke on them.
    [color=blue]
    > </SCRIPT>
    >
    > The form on the popup window is this:
    >
    > <form action="primos. php" method="POST">[/color]
    ....[color=blue]
    > How can I get the form to send the info to "primos.php " and open it in
    > the original window?[/color]

    How do you know that the original window is still open?

    If it is open, you can use the target attribute on the form tag to send
    the result to that window. This requires you to know the name, if any,
    of the original window.

    There is a way to find this name (or set it, if there is no name)
    dynamically:

    <form action="primos. php" method="POST" target="_blank"
    onsubmit="if (!opener.closed ) {
    if (opener.name) {this.target=op ener.name;}
    else {
    this.target = opener.name =
    'primosWindowNa me'+Math.floor( Math.random()*1 0000);
    }}">

    If the original window exists, then we either set the target attribute
    to that window's name. If it has no name, we create a new, random, name
    and assign it to both the target attribute and the window's name.

    Warning, untested code. I did test that you can set the window's name
    dynamically in Opera 7, Mozilla and IE 6.

    This will probably fail if the user has navigated the original window
    away from your pages and onto a new domain.

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    Working...