Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

So, lets say I got a simple form inside a page like this:

<form style="text-align:center;">     <p> STUFF </p> </form> 

I wanna add a button so when the user clicks on it the browser's Print dialog shows up, how can I do that?

Edit: I wanna print the form, not the page.

like image 413
user2962142 Avatar asked Nov 20 '13 16:11

user2962142


People also ask

How do I add a print button to a form?

In the Form Builder, click the Submit button's gear icon to open the properties panel. Go to the Advanced tab. Set the Print Button option to “On”.

How do I print a form from a website?

On your browser, open the form by clicking “view” underneath the form name. Click on file > print in the browser window. If you want to print multiple pages, you can remove the “required” setting from your fields.

How do I add a print button to Google Forms?

To enable the Print button, go to the Form Editor of your form within the form builder and click on the Submit button. A panel will open on the left side of the page. From Additional buttons click the Print option, thus adding the button on your form.


1 Answers

Print the whole page

Try adding a button that calls window.print()

<input type="button" value="Print this page" onClick="window.print()"> 

Print a specific portion/container in a page

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

then in the HTML file, add this script code

<script type="text/javascript">     function printDiv(divName) {         var printContents = document.getElementById(divName).innerHTML;         w=window.open();         w.document.write(printContents);         w.print();         w.close();     } </script> 

Refer Print <div id="printarea"></div> only?

like image 64
Murali Murugesan Avatar answered Sep 24 '22 02:09

Murali Murugesan