-6ren">
gpt4 book ai didi

php - 如何从网页打印特定表格

转载 作者:行者123 更新时间:2023-11-30 12:58:31 25 4
gpt4 key购买 nike

请查看附件截图 My output is displaying like this

当我点击打印按钮时,我只想打印显示的设计框。下面是我的 HTML 和代码

<table width="100%">
<tr>
<td align="center"><table width="590" class="label">
<tr>
<td><table width="550" border="1" id="print_div<?php echo $pr; ?>">
<tr>
<td width="150" class="shipp_td" height="222">

<div class="shipping_address" id="shipping_address"> <b> <?php echo $row['shipfirstname']; ?> &nbsp; <?php echo $row['shiplastname']; ?><br />
<?php echo $row['shipaddress1']; ?><br />
<?php echo $row['shipcity']; ?>,<?php echo $row['shipstate']; ?>,<br />
<?php echo $row['shippostalcode']; ?><br />
<?php echo $row['shipcountry']; ?><br />
<?php echo $row['shipphonenumber']; ?><br />
<?php echo $row['emailaddress']; ?> </b> </div></td>
<td class="product_info"><!--<div class="order_id"><?php //echo $row['orderid']; ?></div>-->

<div class="product_name" id="product_name"><?php echo $row['productname']; ?></div>
<div class="option_name" id="option_name">
<?php
$nicotine = $array1['Nicotine Level'];
$nic = str_replace('Nicotine', 'Nic', $nicotine);
echo $nic;
//echo $row['options']; ?>
</div></td>
</tr>
</table></td>
<td class="print_td"><a href="javascript:void(0)" onclick="printContent('print_div<?php echo $pr; ?>')">Print</a></td>
</tr>
</table></td>
</tr>
</table>

最佳答案

当按下打印链接时,您可以隐藏所有表格,然后仅显示触发打印事件的表格。

这是一个使用 jQuery 和 CSS 的例子:JSFiddle

CSS:

@media print
{
.print-hidden {
display: none;
}

a {
display: none;
}
}

JavaScript:

$(function() {
$("table a").click(function (){
$("body > table").addClass("print-hidden");
$(this).parents("table").last().removeClass("print-hidden");
if (window.print) {
window.print();
}
});
});

关于php - 如何从网页打印特定表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18201634/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com