Welcome visitor
* Login
* Register
It is currently September 20th, 2019, 9:32 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » JavaScript



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  Using buttons to hide or show content
PostPosted: February 11th, 2009, 12:15 am 

Posts: 96
Hi,
I have two tables, each one inside a div, and 3 buttons, the 1st shows table1, the 2nd shows table2 and the 3rd shows both of them. But at the same time I want that the 1st button should hide table2, and viceversa. And this is what I have, thanks in advanced for any help.
<div id = "table1">
  <table>
   //content
  </table>
</div>

<div id = "table2">
  <table>
   //content
  </table>
</div>


Top
 Profile  
 
  Re: Using buttons to hide or show content
PostPosted: February 11th, 2009, 12:28 am 
User avatar

Posts: 86
Put this before the body
<script type="text/javascript">
function ch(what)
{
  document.getElementById('table1').style.display=what==2?'none':'block'
  document.getElementById('table2').style.display=what==1?'none':'block'
}
</script>

and this on the body, these are the buttons
<form action="#">
<p>
<input type="button" value="show table1" onclick="ch(1)">
<input type="button" value="show table2" onclick="ch(2)">
<input type="button" value="show both" onclick="ch(0)">
</p>
</form>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » JavaScript


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron