Skip to main content

I recently needed to post an HTML form into a popup window instead of targeted to the current document or an existing window. The Javascript for doing this is very simple and in this post I show how to post the form into a popup window with regular Javascript and then with jQuery.

/**
 HTML
 -------------------------------------------------------
 <form id="myform" action="..." method="post">
 <!-- form fields etc here -->
 </form>
 */

$(document).ready(function() {
  $('#myform').submit(function() {
    window.open('', 'formpopup', 'width=400,height=400,resizeable,scrollbars');
    this.target = 'formpopup';
  });
});