I would like to know if it is possible for someone to fill a form on my website, but instead of sending it to a email or database, simply print it?

Because we can't handle credit cards here, and I want people to fill in the form, print it, and give it to us with the cash...

Is that possible?
Thanks!!

Just an idea: if you don't need to store those information and your website is not using an SSL Certificate, then it's better to use javascript, so the users can fill the form, display and print it without sending anything to the server.

use javascript

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

Why not use Print button on the browser or keyboard?

Why not use Print button on the browser or keyboard?

the number of helpdesk req there are for 'how do I print this'
If you program a print button right in the middle of the page there is less chance of somebody assuming you CAN'T print because there is no print button
unfortunately not 'no chance' just less chance

without a button you almost have to put detailed instructions on the page how to access 'print'

use javascript

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

Thanks for the code, but is there a way to only print the form and not the entire page?

CSS

@media print { .dontprint { display:none;}
@media screen { .dontshow { display:none; }
<div class='menu dontprint'> this represents the onscreen menu, which you dont want to print</div>
<div class='dontprint'>This is onscreen instructions for the form</div>
<div class='dontshow'>this is different on-paper instructions for the form</div>
<form>bla bla bla this is the form
What is your choice <select class='dontprint' onchange='self.className="";'>
<option>1</option>
<option>2</option>
<option>3</option>
</select><input type='text' class='dontshow'>
<!-- this creates a select box onscreen, but a fill in textbox on paper unless the user has set the value of the select box -->
</form>
<div class='dontprint'> this is anything else you dont want to print</div>
<div class='dontshow'> this is anything else you want to print but dont want to show onscreen</div>
<div class='dontshow dontprint'> this is spambot killer 
<a rel='nofollow'  href='http://www.auditmypc.com/freescan/antispam.html'>I hate spambots</a>
well behaved bots don't follow the link</div>

Thanks !!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.