Connecting Tech Pros Worldwide Help | Site Map

Hiding and Displaying 2 HTML tables in the same place with DHTML

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 09:34 PM
success_ny@yahoo.com
Guest
 
Posts: n/a
Default Hiding and Displaying 2 HTML tables in the same place with DHTML

I would like to be able to display either one or the other HTML table
in the same place. I.e., there are 2 buttons on the screen. When the
user clicks one button, the table A is displayed below. When the user
clicks the other button, the table A disappears and the table B appears
in the same place.

When I use the classic div tags followed by table code, they are
displayed sequentially on the page, rather than in the same place.

Can someone help with a code snippet and advice?

Thanks!!!


  #2  
Old July 23rd, 2005, 09:34 PM
web.dev
Guest
 
Posts: n/a
Default Re: Hiding and Displaying 2 HTML tables in the same place with DHTML

Hi,
[color=blue]
>When I use the classic div tags followed by table code, they are displayed sequentially on the page, rather than in the >same place.[/color]

You may not have provided enough information, but to me it sounds like
you haven't done anything with css? If that is the case, let's assume
table A is the first table displayed like so in your html:

<input type = "button" onClick = "toggleA()" />
<input type = "button" onClick = "toggleB()" />

<div id = "tableA" style = "display: block">
[your tableA code]
</div>

<div id = "tableB" style = "display: none">
[your tableB code]
</div>

Please note this isn't the most efficient of code, but it'll get you
by. In your javascript you could have the following:

function toggleA()
{
document.getElementById("tableB").style.display = "none";
document.getElementById("tableA").style.display = "block";
}

function toggleB()
{
document.getElementById("tableA").style.display = "none";
document.getElementById("tableB").style.display = "block";
}

This will in effect "hide" one table, and in it's place show the other
table instead.

Hope this helps.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.