<inputid= "Btnprint" type= "button" value= "print" onclick= "javascript:window.print ();" /><inputid= "Btnprint" type= "button" value= "Print Preview" Onclick=preview (1)/><styletype= "Text/css" media=print>. Noprint{display:none}</style><pclass= "Noprint" > where printing is not required </p><script>Functionpreview (Oper){if (Oper <10){bdhtml=window.document.body.innerhtml;//get the HTML code for the current pagesprnstr= "<!–startprint" +oper+ "–>";//Set Print start areaeprnstr= "<!–endprint" +oper+ "–>";//Set Print End areaprnhtml=bdhtml.substring (Bdhtml.indexof (SPRNSTR) +18);//Take HTML back from the start codeprnhtmlprnhtml=prnhtml.substring (0,prnhtml.indexof (EPRNSTR));//Fetch HTML from the end codewindow.document.body.innerhtml=prnhtml;window.print ();window.document.body.innerhtml=bdhtml;} else {window.print ();}}</script><p>XXXXX</p><!–startprint1–> What to print <!–endprint1–><inputid= "Btnprint" type= "button" value= "print" onclick= "javascript:window.print ();" /><inputid= "Btnprint" type= "button" value= "Print Preview" Onclick=preview (1)/><styletype= "Text/css" media=print>. Noprint{display:none}</style><pclass= "Noprint" > where printing is not required </p><script>Functionpreview (Oper){if (Oper <10){bdhtml=window.document.body.innerhtml;//get the HTML code for the current pagesprnstr= "<!–startprint" +oper+ "–>";//Set Print start areaeprnstr= "<!–endprint" +oper+ "–>";//Set Print End areaprnhtml=bdhtml.substring (Bdhtml.indexof (SPRNSTR) +18);//Take HTML back from the start codeprnhtmlprnhtml=prnhtml.substring (0,prnhtml.indexof (EPRNSTR));//Fetch HTML from the end codewindow.document.body.innerhtml=prnhtml;window.print ();window.document.body.innerhtml=bdhtml;} else {window.print ();}}</script><p>XXXXX</p><!–startprint1–> What to print <!–endprint1–>
PHP implementation of print preview function