Solved

Hide a Table when I click over image

Posted on 2002-05-20
6
143 Views
Last Modified: 2010-04-09
How to hide a Table when i click over an image and then make the table visible when i click on the image next time.

thanks
0
Comment
Question by:elzohry
  • 3
  • 2
6 Comments
 
LVL 23

Accepted Solution

by:
b1xml2 earned 50 total points
ID: 7023298
to hide the table, use the css property.
applicable to MSIE4+,NS6+
<html>
<head>
<script>
function toggleElement(szId) {
 var el = document.getElementById ? document.getElementById(szId) : document.all ? document.all[szId] : null;
 if (! el) return;
 //try experimenting with block or inline
 el.style.display = el.style.display == "none" ? "block" : "none";
}
</script>
</head>
<body>
<img src="logo.gif" onclick="toggleElement('data');">
<table id="data" style="display:none;">
<tr>
 <td>Hello</td>
</tr>
</table>
</body>
</html>
0
 
LVL 2

Expert Comment

by:jpoesen
ID: 7023544
nice code
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 7023557
thank you =)
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 2

Expert Comment

by:jpoesen
ID: 7023573
finally a perfect example of how to use trinary operators. EE really IS a great place to learn :)
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7023837
Well very pretty, if you don't need to support level 4 browsers and if it only has one image and one table and the user is actually able to understand the code well enough to maintain it.  

Of cross-browser means you actually have to do a little more work in both the script and the HTML.  Of course I'm an old dinosaur, so maybe slick is better, flexible.

elzohry,

If you need to support level 4 browsers, let us know.  I'm sure b1 will be happy to give you a complete solution.

Cd&

0
 
LVL 23

Expert Comment

by:b1xml2
ID: 7023860
cd&
you old codger you =))
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

773 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