return to main window after submit

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

    #1

    return to main window after submit

    I have popup window (window.open) where I put any value in input field.
    After submit I wan to to return to the main window and get value from popup
    window. How to close popup window and return to the main after submit?
  • RobB

    #2
    Re: return to main window after submit

    Piotr wrote:[color=blue]
    > I have popup window (window.open) where I put any value in input[/color]
    field.[color=blue]
    > After submit I wan to to return to the main window and get value from[/color]
    popup[color=blue]
    > window. How to close popup window and return to the main after[/color]
    submit?

    <html>
    <head>
    <title>Master Form Page</title>
    <script type="text/javascript">

    var Fwin = null;

    function openFWin(url)
    {
    var w = 160,
    h = 100,
    l = 200,
    t = 180;
    Fwin =
    open(url,'Fwin' ,'width='+w+',h eight='+h+',lef t='+l+',top='+t +',status=0');
    if (Fwin && !Fwin.closed)
    Fwin.focus();
    return false;
    }

    </script>
    </head>
    <body onload="documen t.mainform.rese t()">
    <form name="mainform" >
    <input name="data" type="text" /><a href="#" onclick="return
    openFWin('formp op.html')">&lar r;set data</a>
    </form>
    </body>
    </html>

    [formpop.html]

    <html>
    <head>
    <title>Pop Up Form</title>
    <script type="text/javascript">

    function transfer_to_ope ner(oSrcForm, sDestFormName)
    {
    if (opener && !opener.closed)
    {
    var f, els;
    if ((f = opener.document .forms[sDestFormName]) && (els = f.elements))
    els['data'].value = oSrcForm.elemen ts.data.value;
    top.close();
    return false;
    }
    }

    </script>
    </head>
    <body bgcolor="#82a4c 8" onblur="setTime out('top.focus( )', 100);">
    <form name="popForm"
    style="width:10 0%;text-align:center;pa dding-top:20px;"
    onsubmit="retur n transfer_to_ope ner(this, 'mainform')">
    <input name="data" type="text" value="enter data"
    onfocus="this.v alue=''" />
    <br /><br />
    <input type="submit" value="done" />
    </form>
    </body>
    </html>

    This doesn't submit the new data, just transfers it over to the 'main'
    window, a typical request. If you want the data submitted, remove
    'top.close();' and 'return false;' from the function, and return an
    action page to the pop-up with a bit of JS that closes the window
    unconditionally .

    Comment

    Working...