Forms in html - How to make a form do 2 things?

I have a form to subscribe to receive an RSS feed via Feedburner. this is the code -

<form action="http://feedburner.google.com/fb/a/mailverify" method="post">
    <p><input name="email" type="text" /></p>
<input name="uri" type="hidden" value="dafyomi" /><input name="loc" type="hidden" value="en_US" /><input type="submit" value="click here to send" /></form>
<p> </p>

      

I want it to also submit the form data to a new window and also change the window the user is currently in - in the thank you page on the site.

Any ideas? Thank!

+2


source to share


3 answers


In pure HTML it is impossible.

You can use JavaScript for this, but it's ugly, breaks usability, and probably most browsers will block it thinking you are trying to display ads.

And since it's not recommended to open a new window / tab / something either, some browser might even ignore your "new window" and try to open it in the current tab. This will result in undefined behavior that tries to open two things in the same window.



You might consider using one landing page and <object/>

or frames to display another, if that's important. But this is also not very useful.

PS. And in all cases, the form can only be submitted on one of the pages. The second one will be a simple GET.

+2


source


I would like to suggest using jQuery Ajax Form Plugins for this case. You can do two actions with one submit form this way ...



$('form').submit(function() {
    $(this).ajaxSubmit({
        url: myurl,              //ajax request to myurl
        success: function() { 
            return true;         //submit form
        }
    });
    return false;
});

      

+1


source


I would add "Thank you!" - a phrase to the results page - it can only be a line or two long ones, right?

If you think this is not an option, you can do something like this:

  • The form is submitted to the server and the relevant data required to view the results page is stored in the session
  • Redirect to the "Thank you" page, with a link to the results page.
  • The link triggers a GET request for the results page, and the results can be displayed thanks to the Session variable.
  • If the page should be available only once, open a session.
+1


source







All Articles