Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.