gpt4 book ai didi

javascript - 我怎样才能制作打印报告的打印按钮?

转载 作者:行者123 更新时间:2023-11-28 06:52:00 25 4
gpt4 key购买 nike

我正在做一个项目,但我的问题是我不知道如何制作打印按钮来打印我的报告..报告在表格中..有人可以帮助我吗一个?我的问题是如何添加打印按钮?

这是我用于查看特定记录的代码

<?php
include_once 'dbconfig.php';
$username = isset($_GET['username']) ? $_GET['username'] : '';
$password = isset($_GET['password']) ? $_GET['password'] : '';
$province = isset($_GET['province']) ? $_GET['province'] : '';

if(isset($_GET['user_id']))
{
$user_id = $_GET['user_id'];
extract($crud->getID($user_id));
}
?>

<body>
<div id="Survey-view">
<div id="header">
</div>

<p><strong>INFORMATION</strong></p>
<hr />
<div id="main-frame">
<table id="information-content" cellspacing="0">
<thead>
<tr>
<th>Username</th>
<th>Password</th>
<th>Province</th>
</tr>
<tbody>
<tr>
<td><?php echo $username; ?></td>
<td><?php echo $password; ?></td>
<td><?php echo $province; ?></td>
</tr>
</tbody>
</thead>
</table>
</div>
<br />
<br />
<p><strong>ASP</strong></p>
<hr />
<div id="asp">
<table id="asp-content" cellspacing="0">
<thead>
<tr>
<th>Date Survey</th>
<th>Date Submitted</th>
<th>Date Approved</th>
<th>Date Recv'd by Region</th>
<th>Date Recv'd by DARPO</th>
</tr>
<tbody>
<tr>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
</tr>
</tbody>
</thead>
</table>
</div><!-- End of asp-->
<br />
<br />
<p><strong>DENR/DARPO</strong></p>
<hr />
<div id="denrdarpo">
<table id="denrdarpo-content" cellspacing="0">
<thead>
<tr>
<th>Date Survey</th>
<th>Date Submitted</th>
<th>Date Approved</th>
<th>Date Recv'd by Region</th>
<th>Date Recv'd by DARPO</th>
</tr>
<tbody>
<tr>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
</tr>
</tbody>
</thead>
</table>
</div><!--End of denrdarpo-->
<br />
<br />
<p><strong>OTHERS</strong></p>
<hr />
<div id="others">
<table id="others-content" cellspacing="0">
<tr>
<td>Project Number</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Module Number</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Fund Year</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>LAD Target</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Land Category</td>
<td><select disabled>
<option><?php echo $username; ?></option>
</select></td>
<td>LAnd Type</td>
<td><select disabled>
<option><?php echo $username; ?></option>
</select></td>
</tr>
<tr>
<td>Date Reported</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Date Suspended</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Date Completed</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Number of Lots</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Station</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Contractor</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Agency</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Cert 40</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
</table>
</div>
</div>
</body>

最佳答案

每次我需要这样做时,我都会转到我的旧 Gmail 帐户,打印一页,然后查看源代码,因为我懒得记住这些功能。

Google 就是这样做的。

<script type="text/javascript">// <![CDATA[
document.body.onload=function(){document.body.offsetHeight;window.print()};
// ]]></script>

您可以轻松地将其附加到按钮,而不是在加载时执行。

<button onclick="document.body.offsetHeight;window.print();">Print</button>

Here's a working example.

这个将从打印页面上删除按钮:

<button onclick="this.style.display='none';document.body.offsetHeight;window.print();this.style.display='inline';">Print</button>

And another example.

关于javascript - 我怎样才能制作打印报告的打印按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32878858/

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