View Full Version : Help with table display:none etc

09-26-2005, 11:56 PM
Well, i have serveral tables generated with php and calling from an SQL database, which they work fine etc etc. Now i only want one table to display at a time. Heres the coding im trying. Right now im only dealing with 2 tables. But in the end, as more data is added to the database, it adds more tables, or pages, in this instant.

<table cellpadding=0 cellspacing=0 border=0 id="1" />

And below is buttons, well, are suppost to be, i cant get those working either...

<center>&laquo;<SPAN onClick="Pages(1,2)">1.</SPAN>

<SPAN onClick="Pages(2,2)">2</SPAN>&raquo;</center>

And my function

<script language="javascript">';

function Pages(number,tpages) {
var num = number
if (num == 1) {
document.getElementById(number).style.display = "";
document.getElementById(2).style.display = "none";
if (num == 2) {
document.getElementbyID(number).style.display = "";
document.getElementById(1).style.display = "";

Please some1 tell me why it doesnt work???

09-27-2005, 06:59 AM
several reasons:
getElementById is case sensitive, one of yours looks like this "getElementbyID"
This line
document.getElementById(1).style.display = ""; needs none inside the quotes.
Your table tags need to look like this:
<table width=520 border=0 cellpadding=0 cellspacing=0 id="1"><tr><td>table 1</td></tr>
<table cellpadding=0 cellspacing=0 border=0 id="2"><tr><td>table 2</td></tr>
You can't self close a table tag with />, well I suppose you can but it then has no cells!
Good luck.

09-27-2005, 12:58 PM
no no no, as i said, these are huge tables, and they are complete, and for the slash it was in php., and i took it out.

What i need help is its not changing the displays and i dont know why...

09-27-2005, 06:51 PM
An "ID" cannot be just a number.

The initial must be a letter (a-zA-Z) and then following character can be letters or numbers

09-27-2005, 08:37 PM
i solved it....with lots of time and alot of patience.