我需要做的是当表单提交时以新窗口模式打开。我在Javascript Post on Form Submit open a new window中得到了这个脚本。当我尝试提交表单时,它不起作用。任何帮助都会受到欢迎。
的index.php
<form id="formprint" name="formprint">
<input type="text" name="search" id="search">
<input type="submit" name="print" value="print"/>
</form>
<script>
var form = document.getElementById("formprint");
form.setAttribute("method", "post");
form.setAttribute("action", "print.php");
// setting form target to a window named 'formresult'
form.setAttribute("target", "formresult");
var textField = document.getElementById("search");
textField.setAttribute("name", "search");
form.appendChild(textField);
document.body.appendChild(form);
// creating the 'formresult' window with custom features prior to submitting the form
window.open(../print.php, 'formresult', 'scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no');
form.submit();
</script>
Print.php
<?php
if (isset($_POST['print'])) {
$search = $_POST['search'];
}
?>