SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    Brazil
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Setting an Arrays Visibility

    Thanks a lot!

    Now for the second part. I´m trying to call one of the table using a link, but do I have to type an if for each variable of the array? Heres the code:

    <script language="javascript">


    // Função que seta as Variáveis do Array para Display = "none";

    function start()
    {

    //Variáveis criadas no Array
    var table = new Array (3);
    table[0] = "tabela";
    table[1] = "tabela1";
    table[2] = "tabela2";

    for (i = 0; i < table.length; i++)
    {
    document.getElementById(table[i]).style.display = "none";
    }

    }
    </script>



    </head>

    <body onload="start()";>
    <a href="javascript:change('tabela')">Tabela</a>
    <a href="javascript:change('tabela1')">Tabela 1</a>
    <a href="javascript:change('tabela2')">Tabela 2</a>










    Hello all,

    Well, this may be a really noob question, it is actually, but I need a little help to start with it. I created an array, naming three tables, but I want to set all of them to invisible when the page loads. So I was wondering how I can set the array visibility. Here something I have tryed but no success. Hope you guys can give me a hand. Thanks!

    function start()
    {
    var table = new Array (3);
    table[0] = "tabela";
    table[1] = "tabela1";
    table[2] = "tabela2";

    table[i].display = "none";
    }
    Last edited by Belerofonte; Feb 28, 2005 at 12:36. Reason: Now to call each table individually setting only that element Visible

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    function start()
    {
    var 
    table = new Array (3);
    table[0] = "tabela";
    table[1] = "tabela1";
    table[2] = "tabela2";

     for (
    i=0;i<table.length;i++){
      
    document.getElementById(table[i]).style.display "none";
     }
    }
    </
    head>
    <
    body onload="start();" 
    This assums that the array field values are the ids of the tables

    or better still



    PHP Code:
    between the <headtags
    <style>
    .
    TableClass position:relative;display:none; }
    <
    style
    and inset class="TableClass" in the <table> tag of the reqd tables.

    but this is a JS forum


Bookmarks

Posting Permissions

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