Forum Moderators: not2easy

Message Too Old, No Replies

How can I print a specific table?

         

joe1182

8:01 pm on Dec 19, 2004 (gmt 0)

10+ Year Member



I have a table "example". I have added print button through javascript. I want when someone clicks print that only the information inside the table will be printed anything outside the table will be excluded. How should I go about doing this? Does anyone have a simple solution?

Robin_reala

9:04 pm on Dec 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Put a class="noprint" attribute on everything other major container of your page, and set up a print stylesheet ( <link rel="stylesheet" media="print" src="print.css"> ) with the contents:

.noprint {
display: none;
}

victor

10:30 pm on Dec 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A separate print sytle sheet is definitely the way to go.

You may be able to improve on Robin's approach and make far fewer changes to the page. That could be useful if you have a lot of other major containers on the page.

In the print style sheet, set everything to not print:

* {
display: none;
}

html {
display: none;
}

Then have one other style, say:

.to-print {
display: block
}

and style your table with that.

Robin_reala

11:44 pm on Dec 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does display: block work on tables? I thought you had to use display: table?

joe1182

2:18 am on Dec 20, 2004 (gmt 0)

10+ Year Member



Thanks guys for the help I beleive this is what I need to help me solve the problem.