B-219 Sec-55 Noida, India
+918010221733

How can I insert a Print button that prints a form in a webpage

Try adding a button that calls window.print()

<input type="button" value="Print this page" onClick="window.print()">
 
 For specific area of a page
 
<div id="print-content">
<form>

<input type="button" onclick="printDiv('print-content')" value="print a div!"/>
</form>
</div>

 then in HTML file add this script code

<script type="text/javascript">

function printDiv(divName) {
alert('s');
var printContents = document.getElementById(divName).innerHTML;
w=window.open();
w.document.write(printContents);
w.print();
w.close();
}
</script> 
(Visited 125 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.