在我的单页我有两个表。第一个表是基本信息表。在其他我将有列表的列表顺序。我想打印只有第二个表。如何做到这一点。
这不是基本的打印,用打印按钮我想单独打印第二个表的内容。
这是代码,我可以打印第二个表,但css没有得到应用,它没有打印,因为它在屏幕上。
<script language="javascript">
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
</script>
<table width="100%" class="ticketpopup" id='first'>
<tr>
<td class='label-column' width="100">Address1</td>
<td class='value-column' width="200" ><?echo $Address1?></td>
<td class='label-column' width="100">Address2</td>
<td class='value-column' width="200"><?echo $Address2?></td>
</tr>
<tr>
<td class='label-column' width="100">Suburb</td>
<td class='value-column' width="200" ><?echo $Suburb?></td>
<td class='label-column' width="100">State</td>
<td class='value-column' width="200"><?echo $State?></td>
</tr>
<tr>
<td class='label-column' width="100">Postcode</td>
<td class='value-column' width="200" ><?echo $Postcode?></td>
<td class='label-column' width="100">Telephone1</td>
<td class='value-column' width="200"><?echo $Telephone1?></td>
</tr>
<tr>
<td class='label-column' width="100">FAX </td>
<td class='value-column' width="200" ><?echo $FAX?></td>
<td class='label-column' width="100">ISPCode</td>
<td class='value-column' width="200"><?echo $ISPCode?></td>
</tr>
<tr>
<td class='label-column' width="100">Email</td>
<td class='value-column' width="200" ><?echo $Email?></td>
<td class='label-column' width="100">PosSoftware</td>
<td class='value-column' width="200"><?echo $PosSoftware?></td>
</tr>
</table>
<table id="second">
<?
for ($i=0;$i<10;$i++)
{
print "<tr><td class='label-column' width='100'>Item Name</td>
<td class='value-column' width='200'><?echo $value[$i];?></td>";
}
?>
</table>
<a href="javascript:void(printDiv('second'));">Print</a>
1条答案
按热度按时间e5njpo681#
您可以尝试使用jQuery: