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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show and hide table from a single element click

Status
Not open for further replies.

BobbaFet

Programmer
Feb 25, 2001
903
NL
Hey all,

For me it's been a long time since I worked with JavaScript and I managed to get this bit of code to work in IE, but not in FF. Can anyone clue me in where I'm going wrong or what I should change to get it to work FF as well?

It is supposed to show or hide the table when the user clicks on the header tag .

Sample of the webpage:
Code:
<html><head><title>Het nieuws van 19-01-2011</title>

      <script type="text/JavaScript1.2">
      function ShowHide(myTable)
      {
      var thisTable = document.getElementById(myTable);

      if (thisTable.style.display == "none")
      {
      thisTable.style.display = "block";
      }
      else
      {
      thisTable.style.display = "none";
      }

      }
      </script>

</head><body>
<div><h1><center>Het overzicht van PAROOL.nl</center></h1></div>
<br><br><h2 onClick="javascript:ShowHide('PAAmsterdam')">Amsterdam</h2><br><br>
<div id="PAAmsterdam"><table width="100%" cellspacing="20px" cellpadding="0px">
<tr><td>stuff</td>
<td>stuff</td>
<td>stuff</td>
<td>stuff</td></tr>
<tr><td>stuff</td>
<td>stuff</td>
<td>stuff</td>
<td>stuff</td></tr>
</table></div>
</body></html>

[bobafett] BobbaFet [bobafett]
Code:
if not Programming = 'Severe Migraine' then
                       ShowMessage('Eureka!');
 
Check FF's error console, and you'll notice you have an error. "ShowHide is not defined"

That's because FF does not support version numbers in the type attribute of the script tag. simply stating its javascript is all that's needed.


Code:
<script type="type/[red]javascript[/red]">


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown. 

Behind the Web, Tips and Tricks for Web Development. 
[URL unfurl="true"]http://behindtheweb.blogspot.com/[/URL]
 
Ah thanks so much! I never noticed FF gave an error? Where do I find that?

[bobafett] BobbaFet [bobafett]
Code:
if not Programming = 'Severe Migraine' then
                       ShowMessage('Eureka!');
 
BobbaFet said:
I never noticed FF gave an error? Where do I find that?

ME said:
Check FF's error console

In the Tools Menu.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top