SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    make the repetition simple

    Code:
    <script type=text/javascript>
    <!--
    
    function hide_table()
    {
    document.getElementById('table1').style.display = "none";
    document.getElementById('table2').style.display = "none";
    document.getElementById('table3').style.display = "none";
    document.getElementById('table4').style.display = "none";
    document.getElementById('table5').style.display = "none";
    document.getElementById('table6').style.display = "none";
    document.getElementById('table7').style.display = "none";
    document.getElementById('table8').style.display = "none";
    document.getElementById('table9').style.display = "none";
    document.getElementById('table10').style.display = "none";
    
    }
    function show_table(tablediv)
    {
    hide_table();
    
    document.getElementById(tablediv).style.display = "block";
    }
    
    -->
    </script>
    
    
    <br><br>
    
    <table>
    <tr>
    <td>
            <a href="javascript:show_table('table1');">table1</a>
    </td>
    <td>
            <a href="javascript:show_table('table2');">table2</a>
    </td>
    <td>
            <a href="javascript:show_table('table3');">table3</a>
    </td>
    <td>
            <a href="javascript:show_table('table4');">table4</a>
    </td>
    <td>
            <a href="javascript:show_table('table5');">table5</a>
    </td>
    <td>
            <a href="javascript:show_table('table6');">table6</a>
    </td>
    <td>
            <a href="javascript:show_table('table7');">table7</a>
    </td>
    <td>
            <a href="javascript:show_table('table8');">table8</a>
    </td>
    <td>
            <a href="javascript:show_table('table9');">table9</a>
    </td>
    <td>
            <a href="javascript:show_table('table10');">table10</a>
    </td>
    
    </tr>
    
    <tr>
      <td colspan='10'>
    <table id='Table1' style="display:block">
    <tr>
    <td>table1</td>
    </tr>
    </table>
    
    <table id='Table2' style='display: none'>
    <tr>
    <td>table2</td>
    </tr>
    </table>
    
    <table id='Table3' style='display: none'>
    <tr>
    <td>table3</td>
    </tr>
    </table>
    
    <table id='Table4' style='display: none'>
    <tr>
    <td>table4</td>
    </tr>
    </table>
    
    <table id='Table5'  style='display: none'>
    <tr>
    <td>table5</td>
    </tr>
    </table>
    
    <table id='Table6'  style='display: none'>
    <tr>
    <td>table6</td>
    </tr>
    </table>
    
    <table id='Table7'  style='display: none'>
    <tr>
    <td>table7</td>
    </tr>
    </table>
    
    <table id='Table8' style='display: none'>
    <tr>
    <td>table8</td>
    </tr>
    </table>
    
    <table id='Table9'  style='display: none'>
    <tr>
    <td>table9</td>
    </tr>
    </table>
    
    <table id='Table10' style='display: none'>
    <tr>
    <td>table10</td>
    </tr>
    </table>
    
    </td>
    <tr>
    </table>
    I like to make the +1 repetition which is written in red simple.

    Can I make it with your help?
    Is there any looping command in javascript?

  2. #2
    SitePoint Zealot coothead's Avatar
    Join Date
    Jan 2005
    Location
    Chertsey, London, England
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there joon,

    does this help....
    Code:
    <script type="text/javascript">
    <!--
    function hide_table(){
    for(c=1;c<=10;c++) {
       document.getElementById('table'+c).style.display='none';
      }
     }
    //-->
    </script>
    coothead


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
  •