Javascript 我的打印处方功能不起作用
这是我的密码。我想在“使用处方”按钮中打印患者处方详细信息。我的问题是处方按钮不起作用。该功能不起作用Javascript 我的打印处方功能不起作用,javascript,Javascript,这是我的密码。我想在“使用处方”按钮中打印患者处方详细信息。我的问题是处方按钮不起作用。该功能不起作用 <div id="prescription_print"> table width="100%" border="0"> <tr> <TD align="left" valign="top"> <?php f
<div id="prescription_print">
table width="100%" border="0">
<tr>
<TD align="left" valign="top">
<?php foreach ($patient_info as $row2){ ?>
<?php echo 'Patient Name: '.$row2['name']; ?><br>
<?php echo 'Age: '.$row2['age']; ?><br>
<?php echo 'Sex: '.$row2['sex']; ?><br>
<?php } ?>
</td>
<td align="right" valign="top">
<?php $name = $this->db->get_where('doctor' , array('doctor_id' => $row['doctor_id'] ))->row()->name;
echo 'Doctor Name: '.$name;?><br>
<?php echo 'Date: '.date("d M, Y", $row['timestamp']); ?><br>
<?php echo 'Time: '.date("H:i", $row['timestamp']); ?><br>
</td>
</tr>
</table>
</div>
<!----------- prescription button------>
<a onClick="PrintElem('#prescription_print')" class="btn btn-primary btn-icon icon-left hidden-print">
Print Prescription
<i class="entypo-doc-text"></i>
</a>
<?php endforeach; ?>
<!----------- prescription function------>
<script type="text/javascript">
function PrintElem(elem)
{
Popup($(elem).html());
}
function Popup(data)
{
var mywindow = window.open('', 'prescription', 'height=400,width=600');
mywindow.document.write('<html><head><title>Prescription</title>');
mywindow.document.write('<link rel="stylesheet" href="assets/css/neon-theme.css" type="text/css" />');
mywindow.document.write('<link rel="stylesheet" href="assets/js/datatables/responsive/css/datatables.responsive.css"
type="text/css" />');
mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.print();
mywindow.close();
return true;
}
</script>
表格宽度=“100%”边框=“0”>
打印处方
函数PrintElem(elem)
{
弹出($(elem.html());
}
功能弹出窗口(数据)
{
var mywindow=window.open(“”,“处方”,“高度=400,宽度=600”);
mywindow.document.write(“处方”);
mywindow.document.write(“”);
mywindow.document.write(“”);
mywindow.document.write(“”);
mywindow.document.write(数据);
mywindow.document.write(“”);
mywindow.print();
mywindow.close();
返回true;
}
您已经写了这一行:
mywindow.document.write('<link rel="stylesheet" href="assets/js/datatables/responsive/css/datatables.responsive.css"
type="text/css" />');
mywindow.document.write(“”);
两行(字符串包含换行符)。这会使JavaScript无效,因此不会创建函数
移除断线,它就会工作
它的确切意思是“它不工作”?这不是完整的代码。有一个
endforach代码>没有它的开始。您是否多次使用相同的ID#处方(打印
)?ID必须是唯一的。您的浏览器控制台中是否有任何javascript错误?还要确保您的浏览器没有阻止弹出窗口。