Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with table display:none etc

    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.

    Code:
    <table cellpadding=0 cellspacing=0 border=0 id="1" />
    And below is buttons, well, are suppost to be, i cant get those working either...
    Code:
    <center>&laquo;<SPAN onClick="Pages(1,2)">1.</SPAN>
    
    <SPAN onClick="Pages(2,2)">2</SPAN>&raquo;</center>
    And my function
    Code:
    <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 = "";
    }
    }
    </script>
    Please some1 tell me why it doesnt work???
    Last edited by KamikaziRunner; 09-27-2005 at 11:58 AM.

  • #2
    New Coder
    Join Date
    Sep 2005
    Location
    New Zealand
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>
    <table cellpadding=0 cellspacing=0 border=0 id="2"><tr><td>table 2</td></tr>
    </table>
    You can't self close a table tag with />, well I suppose you can but it then has no cells!
    Good luck.
    Paul
    ScrypTik Javascript editor with built in syntax error checking

  • #3
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...

  • #4
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    881
    Thanks
    0
    Thanked 115 Times in 114 Posts
    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

  • #5
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i solved it....with lots of time and alot of patience.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •