title: pure javascript table row pagination
body: <p>I try to do pagination table but I want to reference table row to show 3 data per page</p>
  <p>How Could i do</p>
  <p>Fiddle: <a href="http://jsfiddle.net/578hmpv2/" rel="nofollow noreferrer">http://jsfiddle.net/578hmpv2/</a></p>
  <p>This Code</p>
  <pre><code>var current_page = 1;
  var records_per_page = 3;
  var l = document.getElementById(&quot;listingTable&quot;).rows.length
  
  
  function prevPage()
  {
      if (current_page &gt; 1) {
          current_page--;
          changePage(current_page);
      }
  }
  
  function nextPage()
  {
      if (current_page &lt; numPages()) {
          current_page++;
          changePage(current_page);
      }
  }
      
  function changePage(page)
  {
      var btn_next = document.getElementById(&quot;btn_next&quot;);
      var btn_prev = document.getElementById(&quot;btn_prev&quot;);
      var listing_table = document.getElementById(&quot;listingTable&quot;);
      var page_span = document.getElementById(&quot;page&quot;);
   
      // Validate page
      if (page &lt; 1) page = 1;
      if (page &gt; numPages()) page = numPages();
  
  
      for (var i = (page-1) * records_per_page; i &lt; (page * records_per_page) &amp;&amp; i &lt; l; i++) {
     
               listing_table.rows[i].style.display = &quot;&quot;              
      }
      
      page_span.innerHTML = page + &quot;/&quot; + numPages();
  
      if (page == 1) {
          btn_prev.style.visibility = &quot;hidden&quot;;
      } else {
          btn_prev.style.visibility = &quot;visible&quot;;
      }
  
      if (page == numPages()) {
          btn_next.style.visibility = &quot;hidden&quot;;
      } else {
          btn_next.style.visibility = &quot;visible&quot;;
      }
  }
  
  function numPages()
  {
      return Math.ceil(l / records_per_page);
  }
  
  window.onload = function() {
      changePage(1);
  };
  </code></pre>
  <p>How can I change it to make it perfect? Sorry for my bad English, can't explain all what I need, hope you understand what I need!</p>
  <p>Thanks !</p>