Jump to content

print script


ilikephp

Recommended Posts

You can do it using this trick:

 

1.open a popup window

2. write there the value of a desired text box

3. open print dialog automatically

 

Here's an example similar to the one I used once:

 

function printtext(elem) {

popup = window.open('','popup','toolbar=no,menubar=no,width=200,height=150');

popup.document.open();

popup.document.write("<html><head></head><body onload='print()'>");

popup.document.write(elem);

popup.document.write("</body></html>");

popup.document.close();

}

 

Then you should call it like this:

<form name=f1>

. . .

<input type=text name=t1>

<input type=button value="print it" onclick="printtext(document.f1.t1.value)">

 

<textarea name=t2></textarea>

<input type=button value="print it" onclick="printtext(document.f1.t2.value)">

 

Very simple and effective.

You can also print the entire form by looping through it's elements.

Link to comment
https://forums.phpfreaks.com/topic/186248-print-script/#findComment-983613
Share on other sites

You can print certain areas of code only..

Have a read of this

http://www.digital-web.com/articles/css_styling_for_print_and_other_media/

 

You can apply styles for printing only so if your site has a whole heap of advertisments etc you can hide them within CSS so when the user clicks print it will only display what you want printed..

Link to comment
https://forums.phpfreaks.com/topic/186248-print-script/#findComment-983621
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.