gpt4 book ai didi

JavaScript 或 jQuery 用于以检查格式打印行条目 表的每一行应通过打印链接单独打印

转载 作者:行者123 更新时间:2023-12-03 01:06:44 24 4
gpt4 key购买 nike

[这是我基于 Django 的项目,我想按行打印此表,打印链接位于表中,该表以 Check 等格式打印特定行条目,请为此建议使用 JavaScript 或 Jquery]

<script>
function Print() {
var docprint = window.open('about:blank', '_blank'); //new page
var oTable = document.getElementById('result_tbl').rows.item(0); //get the 1st row by a selector
docprint.document.open();
docprint.document.write('<html><head><title>Ashley Mattresses</title>'); //write HEAD section
docprint.document.write('</head><body><center>'); //write BODY tag and center tag for printing
docprint.document.write(oTable.innerHTML); //select the TR's HTML and add it to the new page
docprint.document.write('</center></body></html>'); //close BODY tag
docprint.document.close();
docprint.print();
docprint.close();
}
</script>
<div id="print-content">
<b><u><h2 align="center">Duplicate Cheque</h2></b></u>
<table id="result_tbl" class="display" >
<thead>
<tr>
<th>S.No</th>
<th>To_Pay</th>
<th>Amount</th>
<th>Amount_In_Words</th>
<th>Cheque_No</th>
<th>Account_No</th>
<th>Cheque_Date</th>
<th>Print</th>
</tr>
</thead>
<tbody>
{% for duplicate in duplicates %}
<tr>
<td class="sno">&nbsp;</td>
<td>{{duplicate.topay}}</td>
<td>{{duplicate.amount1}}</td>
<td>{{duplicate.amount_string}}</td>
<td>{{duplicate.chequeno}}</td>
<td>{{duplicate.accountno}}</td>
<td>{{duplicate.chequedate}}</td>
<td><a href="javascript:window.print()">Print</a></td>

</tr>
{% endfor %}
<tbody>
</table>

最佳答案

您可以使用以下考试

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<style>
@media print {
#result_tbl tbody tr {
display: none;
}

.printRowStyle {
display: block!important;
}

#result_tbl tbody tr td:first-child,#result_tbl thead tr
th:first-child,#result_tbl tbody tr td:last-child,#result_tbl
thead tr th:last-child{
display: none;
}
}
</style>
<script type="text/ecmascript">
function printRow(obj) {
$(obj).closest('tr').addClass('printRowStyle');
window.print();
$(obj).closest('tr').removeClass('printRowStyle');
}
</script>
</head>
<body>
<table id="result_tbl" class="display">
<thead>
<tr>
<th>S.No</th>
<th>To_Pay</th>
<th>Amount</th>
<th>Amount_In_Words</th>
<th>Cheque_No</th>
<th>Account_No</th>
<th>Cheque_Date</th>
<th>Print</th>
</tr>
</thead>
<tbody>

<tr>
<td class="sno">&nbsp;</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td><a onclick="printRow(this)">Print</a></td>

</tr>
<tr>
<td class="sno">&nbsp;</td>
<td>2</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td><a onclick="printRow(this)">Print</a></td>

</tr>

<tbody>
</table>
</body>
</html>

关于JavaScript 或 jQuery 用于以检查格式打印行条目 表的每一行应通过打印链接单独打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52363852/

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