Print Form Button

liunx

Guest
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.<br />
<br />
I made a button labeled print, but what is the corresponding html text that is necessary to actually make the form print?<br />
<br />
Thank you in advance<!--content-->another question along the same lines...<br />
<br />
will this code work to submit the page? where do i define the e-mail address to submit the page to?<br />
<br />
<br />
<br />
<tr><br />
<td align="center"><font face='Trebuchet MS' new roman size=2><br />
<input type=submit value=Submit> <input type=reset value=Reset><br />
<input type=button value=Print><br />
</font></td><br />
</tr><br />
<br />
<br />
<br />
thank you!<!--content-->or is this all i need at the top of the form:<br />
<br />
<br />
<br />
<form name=feedback action=mailto:[email protected] method=post><!--content-->1. You need to use some javascript. The code would be something like this:<br />
<br />
<input type="button" value="Print" onclick="window.print();"><br />
<br />
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: <!-- m --><a class="postlink" href="http://forums.webdeveloper.com/showthread.php?s=&threadid=9543#post48748">http://forums.webdeveloper.com/showthre ... #post48748</a><!-- m --> If you would like to use the mailto protocol in the form, you will need to do it something like this: <form action="mailto:[email protected]" method="post" enctype="text/plain"><!--content-->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.<br />
<br />
<script type="text/javascript"><br />
<!--<br />
if (window.print && document.getElementById) {<br />
document.write('<button id="print">Print</button>'); <br />
document.getElementById('print').onclick = function () {window.print()}<br />
}<br />
// --><br />
</script><!--content-->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 ;) ) <br />
<br />
All YOU need to do is provide the @print style sheet for your page.<!--content-->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.<!--content-->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.<!--content-->use javascript<!--content-->Originally posted by Vladdy <br />
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. <br />
<br />
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.<br />
<br />
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<!--content-->
 
Back
Top