Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

prevent table from printing? 1

Status
Not open for further replies.

ideasworking

Programmer
Dec 2, 2001
120
CA
Hello,

I have created several web reports that I would like to print without the menu across the top of the page. I have placed the menu in a table... so I'm wondering if I can prevent printing of that table? If not... I'm wondering if I can use a button to print a similiar page that doesn't have the menu table? I'd like this second page to simply print, not display.

Maybe there are other options I'm unaware of... anyone have a suggestion(s)?

Thanks,
Lou
 
Use CSS to do this by creating a class that is set to not display the element if the media is print (if you are printing - or print previewing):
Code:
<html><head>...
<style type="text/css" media="print">
[b].noprint[/b] { display: none; }
</style>
...<head><body>...
<table [b]class="noprint"[/b]>
<tr><td>...</td></tr>
</table>
...</body></html>
Cheers.
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
add the media="print" parameter to a new style tag, then apply the display:none property to your table inside that style tag, here's a small example:
Code:
<html>
<head>
<style type="text/css" [!]media="print"[/!]>

#noPrintTable {
   display:none;
}

</style>
</head>
<body>
   <table id="noPrintTable" border="1">
      <tr>
         <td>Test</td>
         <td>Test</td>
         <td>Test</td>
         <td>Test</td>
      </tr>
      <tr>
         <td>Test</td>
         <td>Test</td>
         <td>Test</td>
         <td>Test</td>
      </tr>
   </table>
   <p>This is a print test, print this page and the table will not be on the printout</p>
</body>
</html>

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top