How to print page wise total in html table using java script in print format

时间:2017-08-05 12:17:57

标签: javascript jquery html

I have a html table with 20 columns when i print the table with window.print function in first page 10 columns are displayed, now i need 10 columns totals in current page and next 10 columns totals in other with the wrt 10 columns totals.

1 个答案:

答案 0 :(得分:0)

I had a same problem. Google it and got answer for this. Try this code, i hope it will work for you also. I am using this javascript code for printing my documents that have table and table contains many rows and column

<script type="text/javascript">
        function printDiv(divName) {
            var printContents = document.getElementById(divName).innerHTML;
            var originalContents = document.body.innerHTML;
            document.body.innerHTML = printContents;
            window.print();
            document.body.innerHTML = originalContents;
        }
</script>

HTML Code:

<div id="PrintDiv"></div>

AND Call on button click Button

<input type="button" onclick="JavaScript: printDiv('PrintDiv');"" value="Print" class="btn btn-default" id="btnPrint" />

Use this javascript code