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
    Mar 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to create popup confirmation after submit?

    I wish to open a new window to confirm that data has been submitted from a form.

    I am using a 'submit' button with form method=post and action="mailto:xyz"

    At present, 'submitting' the form results in a popup window, which is presumably generated by Windows XP or Outlook, warning that an e mail will be sent and asking for confirmation. After clicking Ok, the data is submitted but the form still remains on the screen.

    I would like a script to perform actions in the following order, after the automatic e mail warning popup is closed by the user:

    1 Open another window 'thanks.html' which confirms that the form data has been sent. This page would have a 'close this window' button.
    2 After the thanks window has been closed by the user, also close the form window and return to the calling page.

    Not being a programmer, I am a 'cut and paste' script user but can't find anything suitable. I would be most grateful if someone could provide a suitable script.

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can look here for examples of what you are wanting to do.

    .....Willy

  • #3
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Willy. That link is useful for the basic function.

    However, the example given does not close the window of the original data input form, which is what I want to do. Also, where in the script would I add the submit function to send the data by e mail?

    The actions I need to perform are:

    submit the data
    open the popup confirmation window
    close the confirmation window (when user clicks button) and simultaneously (if possible) close the form window
    Last edited by stringer; 03-15-2004 at 08:24 PM.

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Break your task down into small steps.
    First do what you can and then post a link or the code and someone will try to point you in the right direction for each step.

    I'm more than happy to help but I'm not going to code a main page to pop the form window, the form confirmation window and the form thanks window just to show you how to close the window. Which BTW would be something like:

    onload="javascript:opener.close()"

    Help us help you by providing something to work with.
    Even if it is just your form page.

    .....Willy

  • #5
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Apologies! The following is the code for a window 'popup test.html' that does almost everything I want, except that Windows asks to confirm closing the 'popup test' window before the 'thanks.html' popup appears. It would be tidier if 'popup test' could be closed after 'thanks.html' is closed. I have tried putting the window.close() statement after the window.open(), but it then closes the current window (thanks.html) rather than the original one.

    <html>
    <head>
    <script type="text/javascript">
    //<![CDATA[
    function popupform(f) {
    var url = "thanks.html"
    var width = 300;
    var height = 200;
    var screenX = (screen.width/2 - width/2);
    var screenY = (screen.height/2 - height/2);
    var features= "width=" + width + ",height=" + height;
    features += ",screenX=" + screenX + ",left=" + screenX;
    features += ",screenY=" + screenY +",top=" + screenY+", scrollbars=1";
    f.submit();
    window.close('popup test.html')
    var mywin=window.open(url, "popup", features);
    mywin.focus();
    }
    //]]>
    </script>
    </head>
    <body>

    <form method="post" action="mailto:xyz@abc.co.uk" >
    <input type="text" name="formitem1" value="value1">
    <input type="text" name="formitem2" value="value2">
    <input type="button" value="Click" onclick="popupform(this.form)" >
    </form>
    </body>
    </html>


    </body>

    </html>
    before before
    Last edited by stringer; 03-16-2004 at 08:23 AM.

  • #6
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Windows asking to confirm closing the window is a security issue. Although there are hacks to close the window without a confirmation, it is unadvised to use these because it will completely close an AOL browser.

    To properly avoid the confirmation alert, you will need to open the form window from another window just as you are the thanks window. (that's what a meant about the main page) in my previous post.

    Try placing your form codes in a popup which is fired from another page. Thereafter you can open and close all of the windows you want.

    .....Willy

  • #7
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    BTW: Instead of using all of these popups. Why not simply submit the form from your page and use document.replace('thanks.htm') to redirect to the thank you page?

    The replace() method will overwrite the form page in the browser history and the user will not be able to return to it thru their back button.

    .....Willy

  • #8
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks again Willy. I don't want to prolong this unnecessarily, so I'll make this my last question.

    I tried document.replace but it produces an error. As document.write works, I can only assume it is something to do with the version of html (3.2).

    I have stuck to the original plan of generating a popup acknowledgement. The code for the function is below. It works satisfactorily except that if the user clicks cancel in the 'send e mail' popup generated by submit(), it still produces the thanks.html window as if the form had been sent. How can I check whether the submit actually took place?

    function popupform(f) {
    var url = "thanks.html"
    var width = 300;
    var height = 200;
    var screenX = (screen.width/2 - width/2);
    var screenY = (screen.height/2 - height/2);
    var features= "width=" + width + ",height=" + height;
    features += ",screenX=" + screenX + ",left=" + screenX;
    features += ",screenY=" + screenY +",top=" + screenY+", scrollbars=1";
    f.submit();
    window.close('prescription form.html');
    var mywin=window.open(url, "popup", features);
    mywin.focus();
    }

  • #9
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Don't worry about how many questions you ask.
    It's all good as long as you are striving to learn.

    But, you misunderstood my suggestion.
    And I meant to say location.replace()

    Here is an example.
    Code:
    <html><body>
    <form method="post" action="mailto:xyz@abc.co.uk" 
    onsubmit="return location.replace('http://google.com')">
    <input type="text" name="formitem1" value="value1">
    <input type="text" name="formitem2" value="value2">
    <input type="submit" value="Submit">
    </form>
    </body>
    </html>
    .....Willy


  •  

    Posting Permissions

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