Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending data to printer

Using php I created dynamical table, which contains all students from my database. I would like now to add an icon of printer, and when user clicks on that icon, to send this table to printer? I saw it on many pages, but how it's done? Tnx in advance...

like image 251
Marin Horvat Avatar asked May 24 '26 03:05

Marin Horvat


1 Answers

Simply use window.print().
Example in jQuery:

<script>
$(function() {
    $("#print").click(function() {
        window.print();
    });
});
</script>
<a id='print'>Print ME</a>

Example in JavaScript:

<script>
function printMe() {
    window.print()
}
</script>
<input type="button" value="Print" onclick="printMe()">
like image 103
Siamak Motlagh Avatar answered May 26 '26 17:05

Siamak Motlagh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!