[英]How to print page wise total in html table using java script in print format
[英]how to print a specific columns in a table using java script or jquery
無論如何要排除表中的列? 我有一個表格,其中包含我想要在打印過程中排除的每一行的選項。
<table class="table table-hover table-bordered" style = "position : relative; left : 0px; top : 0px; width : 100%; height : 10%" id = "tableitems">
<thead>
<th><center>ID</center> </th>
<th><center>Item Name</center> </th>
<th><center>Brand</center> </th>
<th><center>Initial Price</center> </th>
<th><center>Sales Price</center> </th>
<th><center>Quantity</center> </th>
<th><center>Dealer</center> </th>
<th><center>Edit</center> </th>
<th><center>Order</center> </th>
<th><center>Defective</center> </th>
</tr>
</thead>
<tbody>
<?php
foreach($rows as $row){
if($row["Quantity"] < 10){
print "<tr style = 'background-color : crimson; color : black' >";
}else if($row["Quantity"] < 20) {
print "<tr style = 'background-color : yellow; color : black' >";
}else{
}
print "<td>" . $row['ID'] . "</td>";
print "<td>" . $row['ItemName'] . "</td>";
print "<td>" . $row['Brand'] . "</td>";
print "<td>" . $row['InitialPrice'] . "</td>";
print "<td>" . $row['SalesPrice'] . "</td>";
print "<td>" . $row["Quantity"] . "</td>";
print "<td>" . $row["Dealer"] . "</td>";
print "<td><a href='Update.php?id=" . $row["ID"] . "'>Edit</a></td>";
print "<td><a href = '#!' onclick='show_overlay(" . $row['ID'] . ")'>Order</a></td>";
print "<td><a href = '#!' onclick='reorder(" . $row['ID'] . ")'>Defective</a></td>";
print "</tr>";
}
?>
</tbody>
我有這個打印,獲取表值的問題是它還包括表中的選項是否還有一些列排除到表?
<script>
function printData(){
var divToPrint=document.getElementById("tableitems");
newWin= window.open("");
newWin.document.write("<center><h1>Meng and Mher</h1><p>List of Items</p> </center>");
newWin.document.write(divToPrint.outerHTML);
newWin.print();
newWin.close();
}
$('btnprint').on('click',function(){
printData();
})
</script>
您可以添加一行以將css打印到新窗口中以隱藏第n列,如下所示
newWin.document.write("<style> td:nth-child(2){display:none;} </style>");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.