<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title>數據彙總</title> <script type="text/javascript" src="/static/webprj/template.js"></script> <script type="text/javascript" src="/static/webprj/jquery-1.11.2.js"></script> <script type="text/javascript" src="/static/bootstrap/js/bootstrap.min.js"></script> <link rel="stylesheet" type="text/css" href="/static/bootstrap/css/bootstrap.min.css"> <script type="text/javascript" src="/static/bootstrap-table/bootstrap-table.js"></script> <link rel="stylesheet" type="text/css" href="/static/bootstrap-table/bootstrap-table.css"> <style type="text/css"> table,table td,table th{border:1px solid #000;border-collapse:collapse;font-size: 15px;} table tr td{ padding:0px 0px 0px 5px; } table tr th{ text-align:center; } table{ max-width:100%; font-size:12px; } </style> </head> <body> <div> <div id="dv"> <input id="print2" type="button" value="打印"> </div> <table id="table" class="table table-bordered table-hover"> </table> </div> <!--方法2--> <div style="display:none"> <form id="postData_form" method="post" target="_blank"> <!--<form id="postData_form" target="_blank">--> <input name='postData' id='postData' type='hidden' value=''/> </form> </div> <script type="text/javascript"> //var results = document.getElementById("results"); var spinfos={{spinfos|safe}}; $(function(){ $('#table').bootstrapTable({ method: 'get', cache: false, height: 600, striped: true, trimOnSearch: true, checkAll:true, clickToSelect: true, singleSelect: false, pagination: false, pageSize: 10, pageNumber:1, pageList: [10, 20, 50, 100, 200, 500], search: true, showColumns: true, showRefresh: false, showExport: true, columns:[ { field:'state', checkbox:'true' }, { field:'name', title:'名稱', align:"center",valign:"middle",sortable:"true" },{ field:'spec', title:'規格',align:"center",valign:"middle",sortable:"true" },{ field:'code', title:'商品代碼',align:"center",valign:"middle",sortable:"true" },{ field:'munit', title:'單位',align:"center",valign:"middle",sortable:"true" },{ field:'code2', title:'條形碼',align:"center",valign:"middle",sortable:"true" }, { field:'price', title:'價格',align:"center",valign:"middle",sortable:"true" },{ field:'vipprice', title:'會員價',align:"center",valign:"middle",sortable:"true" }], data:spinfos }) $("#print2").click(function(){ printData() }) }) function printData(){ var newspinfos = [] var rows = $.map( $('#table').bootstrapTable('getSelections'),function(row){ return row }); console.log(rows) //console.log(spinfos) var textspinfos = JSON.stringify(rows) console.log(textspinfos) $("#postData").val(textspinfos) var postUrl = "/printprice2" document.getElementById("postData_form").action=postUrl document.getElementById("postData_form").submit() }</script> </body></html>