0

I am trying to print a header on each printed page, I have tried the code standalone and it works fine, but when thrown in below context it only prints on the first page only sample report showing header on first page only.

what am i doing wrong?

    //css style sheet

        <style> 
            @media screen {
                .only_print{
                    display:none;
                }

            }
            @media print {
                .no-print {
                    display: none !important;
                }

            }

        </style>

        <cfoutput>

        <p id="arr1" ></p>
        //below script generates the table wth header tag into <p> arr1


        <script type="text/javascript">
         function disptbl()
            { 
            var str1=localStorage.getItem('schedule');
        var p=localStorage.getItem('payno');
            var str='';
            var result = str1.split(',');

            //create table using thead and tbody

             str += ' <table width="92%" align="center">';
             str += '<thead>';
             str += '<tr class="only_print">';
             str += '<td colspan="3" align="center"> <h2><b>Data For #url.txtl#</b></h2></td>';
             str += '</tr>';
             str += '</thead>';
             str += '<tbody>';

for loop to split data into columns

            for( var x=0; x < p; x++ ){ 
                str += '<tr>';
                str += '<td align="right">'+result[6+x*10]+'</td>';
                str += '<td align="right">'+result[0+x*10]+'</td>';
            str += '</tr>';
            } 

            //assign create table to <p>

           document.getElementById("arr1").innerHTML = str; 
             }

call function

             disptbl();   
        </script>

        </cfoutput>
Cobra_Fast
  • 15,671
  • 8
  • 57
  • 102
safo
  • 1
  • 1
  • Possible duplicate of [How to use HTML to print header and footer on every printed page of a document?](https://stackoverflow.com/questions/1360869/how-to-use-html-to-print-header-and-footer-on-every-printed-page-of-a-document) – Peter B Nov 07 '18 at 15:00
  • From the linked duplicate, especially this seems to apply: https://stackoverflow.com/a/7197225/1220550, quote: `The correct answer is that HTML 5 and CSS3 have no support for printing page header and footers in print media. And while you might be able to simulate it with (1) tables, (2) fixed position blocks - they each have bugs that prevent them from being the ideal general solution.` – Peter B Nov 07 '18 at 15:03

0 Answers0