Click to See Complete Forum and Search --> : Print Form Button


redsand198
07-03-2003, 07:12 AM
I am creating a submit page in a form, and I want to have the option to print the page before it is submitted with all of the values that the user will enter in the fields show up on the printed page.

I made a button labeled print, but what is the corresponding html text that is necessary to actually make the form print?

Thank you in advance

redsand198
07-03-2003, 07:20 AM
another question along the same lines...

will this code work to submit the page? where do i define the e-mail address to submit the page to?



<tr>
<td align="center"><font face='Trebuchet MS' new roman size=2>
<input type=submit value=Submit> <input type=reset value=Reset>
<input type=button value=Print>
</font></td>
</tr>



thank you!

redsand198
07-03-2003, 07:24 AM
or is this all i need at the top of the form:



<form name=feedback action=mailto:redsand198@aol.com method=post>

pyro
07-03-2003, 07:25 AM
1. You need to use some javascript. The code would be something like this:

<input type="button" value="Print" onclick="window.print();">

2. You have two options. One is using the mailto: protocol in your form tag, the other is using server side code to do this. The latter is definitely the best bet, as the mailto method will fail if the user doesn't have email on the computer. If you server supports PHP, look at: http://forums.webdeveloper.com/showthread.php?s=&threadid=9543#post48748 If you would like to use the mailto protocol in the form, you will need to do it something like this: <form action="mailto:you@your.com" method="post" enctype="text/plain">

Charles
07-03-2003, 07:25 AM
Since the button will not do anything for the 13% of users who do not use JavaScript you would do well to draw the button with JavaScript.

<script type="text/javascript">
<!--
if (window.print && document.getElementById) {
document.write('<button id="print">Print</button>');
document.getElementById('print').onclick = function () {window.print()}
}
// -->
</script>

Vladdy
07-03-2003, 07:53 AM
Browsers that have printing capability have the print button as a part of their interface. Why duplicate it? (If the expected IQ of your users is below 60, then you can put a reminder at the bottom of the form that it can be printed using the browser print button ;) )

All YOU need to do is provide the @print style sheet for your page.

DaveSW
07-03-2003, 08:49 AM
I think that Charles point was that if the button was drawn by javascipt it wouldn't appear for anyone without - so anyone without javascript wouldn't start swearing at you for making something which didn't work.

Vladdy
07-03-2003, 09:50 AM
I'm not argueing with Charles. His suggestion is certainly better than just having a button. But I think it is even better not to duplicate browser interface functionality to begin with.

abectech
07-03-2003, 12:56 PM
use javascript

DaveSW
07-04-2003, 10:04 AM
Originally posted by Vladdy
I'm not argueing with Charles. His suggestion is certainly better than just having a button. But I think it is even better not to duplicate browser interface functionality to begin with.

Oh right sorry - I misread your post and took it to mean you shouldn't write the button with javascript when it was in html.

The only time I've found it useful to give a print button is when you're using frames or iframes - many users don't know anything about them and get frustrated when your site prints only the menu bar. LOL