1

对不起,我没有这个问题的具体标题,

我想用 window.open 方法打印一个表单,这是一段脚本:

<?php
include "connect.php";

$test = mysql_query("select * from dataorder order by idorder desc limit 1 ");


if (!test)
die ("Error... " .mysql_error());

while ($row = mysql_fetch_array ($test))
{
echo "ID number   : $row[idorder] <br/><br/>";
echo "Name        : $row[name] <br/><br/>";  
echo "<div>";
echo "<input  type=button name=back    value='back'onClick='parent.location='reserve.php''>";   
echo '<input  type="submit"
          class="btn btn-success"
          name="print" value="print"
       onClick="window.open("print.php?idorder="'.$row['idorder'].'","scrollwindow","top=200,left=350,width=680px,height=500")" 
        style="text-decoration:none">';
echo "</div>";
}
?>

“打印”按钮可以出现,但单击时没有响应。

4

1 回答 1

1

我认为您有多个报价问题(加上空格问题),导致onClick无法正常工作-

echo "<input  type=button name=back    value='back'onClick='parent.location='reserve.php''>"; 
                  ^      ^    ^    ^              ^                                      ^
echo '<input  type="submit"
      class="btn btn-success"
      name="print" value="print"
   onClick="window.open("print.php?idorder="'.$row['idorder'].'","scrollwindow","top=200,left=350,width=680px,height=500")"
                        ^                  ^                   ^ ^            ^ ^                                       ^ 
    style="text-decoration:none">';

尝试这样的事情 -

echo '<input type="button" name="back" value="back" onClick="parent.location=\'reserve.php\'">';   
echo '<input type="submit" class="btn btn-success" name="print" value="print"
       onClick="window.open(\'print.php?idorder='.$row['idorder'].'\',\'scrollwindow\',\'top=200,left=350,width=680px,height=500\')" 
    style="text-decoration:none">';
于 2013-07-06T07:21:41.337 回答