This is quite an interesting question - hadn't thought about it before. So thanks.
We can use the form's onsubmit event to trap the submit action and launch a popup through window.open, but unfortunately the form's contents aren't set in $_POST (or whatever) for the popup even if we let the form submit. (The original window gets values from $_POST, the popup doesn't.)
We can use the JavaScript form.submit function to get round this, but first we need to make sure the form's results appear in the popup by setting the form's target.
This approach also ensures that, without JavaScript, the form will submit normally to the same window.
So the steps are:
- Create a blank popup window.
- Set the form target to the popup.
- Submit the form.
- Return false to stop the original page submitting too.
HTML Code:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<script type="text/javascript">
function popupSubmit()
{
var popupForm;
popupForm = document.getElementById("popupForm");
window.open("", "popupSubmit", "width=500, height=500");
popupForm.target = "popupSubmit";
popupForm.submit();
return false;
}
</script>
</head>
<body>
<form id="popupForm" method="post" action="tstsubmit.php" onsubmit="popupSubmit();">
<input type="text" name="name" />
<input type="submit" value="Submit" />
</form>
</body>
</html>