How to hide/suppress a html table is no data is presented?

Posted on 2013-06-10
Last Modified: 2013-06-10
How to hide/suppress a html table is no data is presented?
Question by:kgittinger
  • 2
  • 2
LVL 16

Expert Comment

by:Brian Pringle
ID: 39234572
Is this data dynamically generated or is it manually entered?  If it is dynamic, then you could include an IF statement to comment out the table so that it does not appear.
LVL 22

Expert Comment

by:Om Prakash
ID: 39234574
The best method is to use a server side language to generate the required table based on the data from database

To hide/show a table you can use the following:
document.getElementById("table_id").display = "";  //Show the table   
document.getElementById("table_id").display = "none";  //Hide the table 

Open in new window


Author Comment

ID: 39234587
The data is dynamically generated.  My if statement returns no data when appropriate, but I cannot seem to hide/suppress the table header/boarders...

I am new to this.  Thank you very much.

Author Comment

ID: 39234635
One more thing.  Each table is formed via a dynamic query.  The tables are not named.   Do the tables need to be named for the above to work?
LVL 16

Accepted Solution

Brian Pringle earned 500 total points
ID: 39234677
You can have the table itself created by ASP, PHP, whatever language you are using on the server.  Then, the creation of the table would be dependent on your IF statement.  

Something like this... (not exact)

IF there is data to put in the table
   document.writeline("<td>" + %firstitem% + "</td>")
And so on...

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

810 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