Solved

hide html table when printing

Posted on 2010-11-18
5
459 Views
Last Modified: 2012-05-10
right now i'm hiding form buttons when printing with the following css:
@media print {
input#DisplayAttachments {
display: none;
}

Open in new window


i would also like to hide the following:
<div class="dhtmlgoodies_question">Notes and Comments </div>
<div class="dhtmlgoodies_answer">
	<div><table width="700" border="0" cellspacing="1" cellpadding="1">

Open in new window


i didn't give you everything in the above snippet, but is there a way to hide that too?
0
Comment
Question by:sknoll84
  • 3
5 Comments
 
LVL 10

Expert Comment

by:stu215
ID: 34168640
0
 
LVL 14

Expert Comment

by:ali_kayahan
ID: 34168977
Am i missing something or is this what you are asking for

@media print {
input#DisplayAttachments {
display: none;
}
#dontprintme{display:none}
}
<div id='dontprintme'>
<div class="dhtmlgoodies_question">Notes and Comments </div>
<div class="dhtmlgoodies_answer">
      <div><table width="700" border="0" cellspacing="1" cellpadding="1">
</div>
0
 
LVL 14

Expert Comment

by:ali_kayahan
ID: 34168988
or better way

@media print {
input#DisplayAttachments , #dontprintme {
display: none;
}

<div id='dontprintme'>
<div class="dhtmlgoodies_question">Notes and Comments </div>
<div class="dhtmlgoodies_answer">
      <div><table width="700" border="0" cellspacing="1" cellpadding="1">
</div>
0
 
LVL 44

Expert Comment

by:scrathcyboy
ID: 34169764
You are probably making the same mistake most new programmers do -- thinking if you hide the DIV that you have incorrectly wrapped around the table structure, it will hide the table.  This is flawed thinking.

1.  first, tables need no enclosing DIV and should not have one because of erroneous inferences that the DIV properties somehow control the table state.  They do NOT.
2.  Remove the DIV, as it is doing nothing but confusing you.
3.  Give the TABLE an ID or NAME, and use CSS to hide it DIRECTLY, not trying to via the DIV.
4.  use the display:none and display:block on the TABLE, just as you would on other HTML elements

WHen you get the DIV out of the way and hide the table directly, it will work fine.  IF not, it won't work.
0
 
LVL 14

Accepted Solution

by:
ali_kayahan earned 500 total points
ID: 34169972
Wrapping the contents that you dont want to display in a class like .hideMe and appending that to your css like ;

@media print {
input#DisplayAttachments , .hideme{
display: none;
}

Open in new window


would be enough
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question