Print multiple DIV

On my page I have a div that loads content from my database. This div can only contain 5 rows. If the database contains more that 5 rows, a new div is created with the same ID). On my screen everything works great. I’m trying to create a print button. So far, the print menu shows when pressed. The only thing going wrong: I can only print the first div. What do I need to adjust to create a page for each div, so every div is printed on a piece of paper?

The div:

[code]


content page 1 comes here
content page 2 comes here
[/code]

My script:

<script> function printDiv(printableArea) { $("#kolomInstellen").hide(); var printContents = document.getElementById('printableArea').innerHTML; var originalContents = document.body.innerHTML; document.body.innerHTML = printContents; window.print(); document.body.innerHTML = originalContents; $("#kolomInstellen").show(); } </script>

a new div is created with the same ID

You cant use the same id more than once in a page.

The id attribute specifies its element’s unique identifier (ID). The value must be unique amongst all the IDs in the element’s home subtree and must contain at least one character. The value must not contain any space characters.

That ^ and target another attribute other that the id. You can add one or target the class.

Sponsor our Newsletter | Privacy Policy | Terms of Service