ilikephp Posted December 24, 2009 Share Posted December 24, 2009 Hello, Is there a script that lets me print a cell in my website. Thanks... Quote Link to comment https://forums.phpfreaks.com/topic/186248-print-script/ Share on other sites More sharing options...
Deoctor Posted December 24, 2009 Share Posted December 24, 2009 can u explain it more.. Quote Link to comment https://forums.phpfreaks.com/topic/186248-print-script/#findComment-983594 Share on other sites More sharing options...
ilikephp Posted December 24, 2009 Author Share Posted December 24, 2009 if there is a text displayed in my website and somone needs to print this text, he can just click on the PRINT link link to print it out. Quote Link to comment https://forums.phpfreaks.com/topic/186248-print-script/#findComment-983599 Share on other sites More sharing options...
Buddski Posted December 24, 2009 Share Posted December 24, 2009 http://www.javascriptkit.com/howto/newtech2.shtml Quote Link to comment https://forums.phpfreaks.com/topic/186248-print-script/#findComment-983600 Share on other sites More sharing options...
Deoctor Posted December 24, 2009 Share Posted December 24, 2009 it cannot be done in php u hve to use javascript as printing is an action done at the client side.. <form> <input type="button" value="Print this page" onClick="window.print()"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/186248-print-script/#findComment-983604 Share on other sites More sharing options...
ilikephp Posted December 24, 2009 Author Share Posted December 24, 2009 thanks for your help guys! 1. Is there a way to print a certain table not the whole page? 2. How can the text that will be printed be displayed in a new page before the print out (just to be checked)? Thanks ... Quote Link to comment https://forums.phpfreaks.com/topic/186248-print-script/#findComment-983610 Share on other sites More sharing options...
Deoctor Posted December 24, 2009 Share Posted December 24, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/186248-print-script/#findComment-983613 Share on other sites More sharing options...
ilikephp Posted December 24, 2009 Author Share Posted December 24, 2009 I got lost :S If I want only the selected table to be printed directly without being opened in a new window. Is it easy? Quote Link to comment https://forums.phpfreaks.com/topic/186248-print-script/#findComment-983618 Share on other sites More sharing options...
Buddski Posted December 24, 2009 Share Posted December 24, 2009 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.. Quote Link to comment https://forums.phpfreaks.com/topic/186248-print-script/#findComment-983621 Share on other sites More sharing options...
ilikephp Posted December 24, 2009 Author Share Posted December 24, 2009 IT WORKS!! THX A LOT Final question: instead of the print button how can I put plz the "print" without a botton? THANKS... Quote Link to comment https://forums.phpfreaks.com/topic/186248-print-script/#findComment-983638 Share on other sites More sharing options...
Buddski Posted December 24, 2009 Share Posted December 24, 2009 <a href="javascript:window.print()">Click here to Print</a> Should do the trick Quote Link to comment https://forums.phpfreaks.com/topic/186248-print-script/#findComment-983649 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.