【问题标题】:Using Windows.print()..print some fields of a form.使用 Windows.print()..打印表单的某些字段。
【发布时间】:2014-01-24 03:55:59
【问题描述】:

我有一个从外部卡读取数据的脚本我在页面上有两个选项,一个用于从卡读取数据并显示另一个是“发送到打印机”选项,当我点击“发送到打印机”时应该只打印必填字段。代码是

<body>
<br>
<div align="center">
<input type="button" value="Read myKad" id="btnRead" class="btn btn-success"><img src="loading.gif" id="loading" style="display:none">  

<script language="javascript">
if (window.print) {
document.write('<input type="button" value="Sent to Printer" id="btnRead" class="btn btn-warning" onClick="window.print()">');
}
</script>
<span id="msg"></span>
</div>
<hr/>
<span id="holder"></span>
</body>
<script>
$(document).ready(function(){
$("#btnRead").click(function(){
$("#imgpp").html("Please wait. Reading Cherry ..... ");
$("#loading").show();
$.ajax({
url: "read.php",
success: function(response){
//$("#imgpp").attr("src","http://192.168.0.4/mykadreader/sample/mypic.jpg?x=<?PHP echo date("Ymdhis"); ?>");
$("#holder").html(response);
$("#imgpp").html("Done Reading ");
$("#loading").hide()    ;   
$(".paper-table").tablecloth({
         theme: "paper",
         striped: true,
         sortable: true,
         condensed: false
       });
}
})
})
});
</script>

【问题讨论】:

    标签: javascript php jquery html printing


    【解决方案1】:

    如果我理解正确,您只想打印部分页面。 您可以使用仅打印的 css 来做到这一点(即隐藏不需要的东西)。

    即css文件将包含在:

    <link rel="stylesheet" type="text/css" href="print.css" media="print" />
    

    然后在此文件中,您可以在任何/所有不需要的元素上设置 display:none。

    【讨论】:

      猜你喜欢
      • 2016-09-12
      • 1970-01-01
      • 1970-01-01
      • 2018-05-01
      • 1970-01-01
      • 2011-10-07
      • 2015-05-23
      • 1970-01-01
      • 2011-08-06
      相关资源
      最近更新 更多