在模态中打印数据

时间:2017-05-09 08:52:38

标签: php mysql

当我点击View按钮时,会弹出该模态。模态包含要打印的详细信息。你能帮忙我该怎么办?提前谢谢。

This will be the pop-up modal when I hit the view button.

以下代码用于查看按钮:

 <div id="dataModal" class="modal fade">  
  <div class="modal-dialog">  
       <div class="modal-content">  
            <div class="modal-header">  
                 <button type="button" class="close" data-dismiss="modal">&times;</button>  
                 <h4 class="modal-title">Work Request</h4>  
            </div>  
            <div class="modal-body" id="request_detail">  
            </div>  
            <div class="modal-footer">  
                 <button type="button" class="btn btn-primary" onclick="window.print();">Print</button>
                 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>  
            </div>  
       </div>  
  </div>  

View Button的脚本:

$(document).on('click', '.view_data', function(){  
       var request_id = $(this).attr("id");  
       if(request_id != '')  
       {  
            $.ajax({  
                 url:"select.php",  
                 method:"POST",  
                 data:{request_id:request_id},  
                 success:function(data){  
                      $('#request_detail').html(data);  
                      $('#dataModal').modal('show');  
                 }  
            });  
       }            
  });   

这个用于打印按钮:

<script>
 $().ready(function () {
    $('.modal.printable').on('shown.bs.modal', function () {
       $('.modal-dialog', this).addClass('focused');
       $('body').addClass('modalprinter');

    if ($(this).hasClass('autoprint')) {
        window.print();
    }
    }).on('hidden.bs.modal', function () {
    $('.modal-dialog', this).removeClass('focused');
    $('body').removeClass('modalprinter');
   });
});

当我点击“打印”按钮时,它正在工作,但是,(只看照片):This is the result of clicking the Print button.

0 个答案:

没有答案