我试图打印我的Mysql记录的输出。我需要打印的是基于搜索输入的值。如何使用onclick功能在新窗口中打开它?任何帮助都会受到欢迎。
的index.php
<input type="text" name="search" id="search"/>
<input type="submit" name="print" value="print" onclick="openWin(); return false;"/>
<script>
function openWin()
{
window.open("../print.php","name","width=900, height=1200,toolbar=no,scrollbars=yes, resizable=yes");
}
</script>
Print.php
if (isset($_POST['print'])) {
$search = $_POST['search'];
}
答案 0 :(得分:0)
您可以将输入放在表单中,然后在提交表单时打开弹出窗口。
http://jsfiddle.net/wvkjfee2/3/
<form id="formID" action="../print.php" method="post">
<input type="text" name="search" id="search"/>
<input type="submit" name="print" value="print"/>
</form>
<script>
var myForm = document.getElementById('formID');
myForm.onsubmit = function() {
var w = window.open('../print.php','Popup_Window','width=900, height=1200,toolbar=no,scrollbars=yes, resizable=yes');
this.target = 'Popup_Window';
return false;
};
</script>