Manage Learn to apply best practices and optimize your operations.

Create a Web print button that omits certain items on the page

Ever want to have a print button on your Web page that only prints certain parts of the page and omits other parts?

Ever want to have a print button on your Web page that only prints certain parts of the page and omits other parts? This can easily be done in Notes with a Hide/When for printing. Here's a way to do it with javascript on the Web.

Simply enclose the parts of the page you wish not to print with the following:

<div id="divNoPrint1">
Dont print this line

Of course the "Dont print this line" is my sample text, and the <div> elements need to be pass-thru HTML.

As you add multiple DIV statements to omit other parts of your page increment the div number (ie "divNoPrint2" and "divNoPrint3" etc.. in place of the divNoPrint1 example above)

Then add the following function to JS Header of the form.

function printPage() {
var numDivs = 20;
for(i=1;i<numDivs;i++) {
    document.all['divNoPrint'+i].style.display = 'none'; }
for(i=1;i<numDivs;i++) {
    document.all['divNoPrint'+i].style.display = ''; }

This function above only supports 20 items, but of course you can change the divNums variable to be a higher number if necessary.

Then add a print button to your page, form, or view template as such:

<div id="divNoPrint3" align=right><a href="#" 
onClick="printPage();"><img src="/icons/actn147.gif" border=0 
alt="Print page"></a></div>

Of course make sure the above code for the print button is pass-thru HTML. (And note how it is using the name "divNoPrint3" so that it wont be printed.)

And thats it. When the print button is clicked the page will appear to jump for a second (hiding the sections that are not to be printed) and then the print dialog box will come up and the page will return to normal.

Dig Deeper on Web Development for Lotus Notes Domino



  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...