Creating an Easy Print Button on Drupal Webforms

Mark Jarrell's picture

Have you ever wanted to add a simple Javascript print button to a webform so that users could print out all of their entered data? I had a need to do this today for a coworker. I thought about working up a custom module, trying to build a custom template file for the form that contained the additional button, but instead decided to store it as simply a "markup" component/question.

Print button shown next to submit button

Basically you just add in the following code:

<div id="edit-actions" class="form-actions form-wrapper"><input id="edit-submit" class="form-submit" value="Print" name="print" onclick="window.print()" type="button" /></div>

This was tested on a D6 site, but the same idea should work perfectly on D7 sites. Enjoy!

Commenting on this Blog entry is closed.

Comments

Printing webforms

Where do you add that code?

Get the print button next to submit

How did you get the print button next to the submit button?

It has always been a desire

It has always been a desire to have this functionality. However, I would have thought that it would make more sense to have this on the submitted form values instead of the submission page.

Ideally I would see:

a. Submit on the submission page; then

b. an Are-You-Sure page with the values and Print Save.