<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Client-side HTML table pagination with JavaScript</title>
	<atom:link href="http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/</link>
	<description>Welcome to the official blog of Luigi R. Viggiano. Beware of imitations.</description>
	<lastBuildDate>Fri, 13 Jan 2012 02:25:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Jonathan</title>
		<link>http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/comment-page-3/#comment-498572</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Tue, 04 Oct 2011 13:50:20 +0000</pubDate>
		<guid isPermaLink="false">http://it.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/#comment-498572</guid>
		<description>Do any of you know how to eliminate the numbers at the bottom of the page?</description>
		<content:encoded><![CDATA[<p>Do any of you know how to eliminate the numbers at the bottom of the page?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ali</title>
		<link>http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/comment-page-3/#comment-498566</link>
		<dc:creator>Ali</dc:creator>
		<pubDate>Tue, 20 Sep 2011 10:54:55 +0000</pubDate>
		<guid isPermaLink="false">http://it.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/#comment-498566</guid>
		<description>Excellent Script. Really does the job but just one thing, my table actually pulls the content and calculate rank before displaying. What happens when I pull the content, it only sort the ranks of current page content rather than the complete table. Once clicked, it does trigger and sort the complete ranks but can&#039;t see a possible quick way to fix it.

In either case, it does the job and is very helpful. Thanks for sharing.</description>
		<content:encoded><![CDATA[<p>Excellent Script. Really does the job but just one thing, my table actually pulls the content and calculate rank before displaying. What happens when I pull the content, it only sort the ranks of current page content rather than the complete table. Once clicked, it does trigger and sort the complete ranks but can&#8217;t see a possible quick way to fix it.</p>
<p>In either case, it does the job and is very helpful. Thanks for sharing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: faisal</title>
		<link>http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/comment-page-3/#comment-498564</link>
		<dc:creator>faisal</dc:creator>
		<pubDate>Thu, 15 Sep 2011 16:59:13 +0000</pubDate>
		<guid isPermaLink="false">http://it.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/#comment-498564</guid>
		<description>hi!!
thanx for the code. It really helps. I want to change style sheet even when I place pointer to any page number. Please help me</description>
		<content:encoded><![CDATA[<p>hi!!<br />
thanx for the code. It really helps. I want to change style sheet even when I place pointer to any page number. Please help me</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shankar</title>
		<link>http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/comment-page-3/#comment-498551</link>
		<dc:creator>Shankar</dc:creator>
		<pubDate>Mon, 29 Aug 2011 07:43:37 +0000</pubDate>
		<guid isPermaLink="false">http://it.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/#comment-498551</guid>
		<description>Hi ,

i need &quot;&lt;&gt;&quot; implementation in this same pagination . First should come before Previous link and Last should come after Next link. can anyone help ....

Thanks in advance.</description>
		<content:encoded><![CDATA[<p>Hi ,</p>
<p>i need &#8220;&lt;&gt;&#8221; implementation in this same pagination . First should come before Previous link and Last should come after Next link. can anyone help &#8230;.</p>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Is there a good step by step tutorial on javascript pagination? - Programmers Goodies</title>
		<link>http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/comment-page-3/#comment-498535</link>
		<dc:creator>Is there a good step by step tutorial on javascript pagination? - Programmers Goodies</dc:creator>
		<pubDate>Sun, 07 Aug 2011 10:27:04 +0000</pubDate>
		<guid isPermaLink="false">http://it.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/#comment-498535</guid>
		<description>[...] http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/ [...]</description>
		<content:encoded><![CDATA[<p>[...] <a href="http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/" rel="nofollow">http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JS Error in IE 8… “Object Required” - Programmers Goodies</title>
		<link>http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/comment-page-3/#comment-498530</link>
		<dc:creator>JS Error in IE 8… “Object Required” - Programmers Goodies</dc:creator>
		<pubDate>Tue, 02 Aug 2011 02:07:21 +0000</pubDate>
		<guid isPermaLink="false">http://it.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/#comment-498530</guid>
		<description>[...] http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/ [...]</description>
		<content:encoded><![CDATA[<p>[...] <a href="http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/" rel="nofollow">http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Churk</title>
		<link>http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/comment-page-3/#comment-498014</link>
		<dc:creator>Churk</dc:creator>
		<pubDate>Mon, 25 Jul 2011 13:53:53 +0000</pubDate>
		<guid isPermaLink="false">http://it.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/#comment-498014</guid>
		<description>I took the liberty to modify this so the pagination numbering look a little more organizable. Major Code change is on showPageNav(), and added showPageNav() call to all of the prev(), next(), and showPage().

There is a slight change to init. Here it is:

&lt;code&gt;

	var pager = new Pager(&#039;panel&#039;, 10);
	pager.init();
	pager.showPageNav(&#039;pager&#039;, &#039;pageNavPosition&#039;, 1);
	pager.showPage(1);

&lt;/code&gt;

&lt;code&gt;
function Pager(tableName, itemsPerPage) {
    this.tableName = tableName;
    this.itemsPerPage = itemsPerPage;
    this.currentPage = 1;
    this.pages = 0;
    this.inited = false;
    this.positionId = &#039;&#039;;
    this.pageName = &#039;&#039;;
    
    this.showRecords = function(from, to) {        
        var rows = document.getElementById(tableName).rows;
        // i starts from 1 to skip table header row
        for (var i = 1; i &lt; rows.length; i  ) {
            if (i  to)  
                rows[i].style.display = &#039;none&#039;;
            else
                rows[i].style.display = &#039;&#039;;
        }
    }
    
    this.showPage = function(pageNumber) {
    	if (! this.inited) {
    		alert(&quot;not inited&quot;);
    		return;
    	}

        var oldPageAnchor = document.getElementById(&#039;pg&#039; this.currentPage);
        oldPageAnchor.className = &#039;pg-normal&#039;;
        
        this.currentPage = pageNumber;
        var newPageAnchor = document.getElementById(&#039;pg&#039; this.currentPage);
        newPageAnchor.className = &#039;pg-selected&#039;;
        
        var from = (pageNumber - 1) * itemsPerPage   1;
        var to = from   itemsPerPage - 1;
        this.showRecords(from, to);
        
        if (pageNumber == 1) {
        	document.getElementById(&#039;prev&#039;).style.display = &#039;none&#039;;
        } else {
        	document.getElementById(&#039;prev&#039;).style.display = &#039;block&#039;;
        }
        
        if (pageNumber == this.pages) {
        	document.getElementById(&#039;next&#039;).style.display = &#039;none&#039;;
        } else {
        	document.getElementById(&#039;next&#039;).style.display = &#039;block&#039;;
        }
        
        this.showPageNav(this.pageName, this.positionId, pageNumber);
    }   
    
    this.prev = function() {
        if (this.currentPage &gt; 1) {
            this.showPage(this.currentPage - 1);
            this.showPageNav(this.pageName, this.positionId, this.currentPage);
        }
    }
    
    this.next = function() {
        if (this.currentPage &lt; this.pages) {
            this.showPage(this.currentPage   1);
            this.showPageNav(this.pageName, this.positionId, this.currentPage);
        }
    }                        
    
    this.init = function() {
        var rows = document.getElementById(tableName).rows;
        var records = (rows.length - 1); 
        this.pages = Math.ceil(records / itemsPerPage);
        this.inited = true;
    }

    this.showPageNav = function(pagerName, positionId, position) {
    	if (!this.inited) {
    		alert(&quot;not inited&quot;);
    		return;
    	}
    	this.pageName = pagerName;
    	this.positionId = positionId;
    	
    	var pagerHtml = &#039; &amp;#171 Prev  &#124; &#039;;
    	if (position &gt; 6) {
    		pagerHtml  = &#039;... &#124; &#039;;
    	}
    	for (var page = (position - 5 &gt; 0 ? position - 5 : 1); page  this.pages ? this.pages : position   6);  page  ) {
            pagerHtml  = &#039;&#039;   page   &#039; &#124; &#039;;
    	}
    	if (position   5 &lt; this.pages) {
    		pagerHtml  = &#039;... &#124; &#039;;
    	}
        pagerHtml  = &#039; Next &#187;&#039;;            
        
        document.getElementById(positionId).innerHTML = pagerHtml;
    }
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I took the liberty to modify this so the pagination numbering look a little more organizable. Major Code change is on showPageNav(), and added showPageNav() call to all of the prev(), next(), and showPage().</p>
<p>There is a slight change to init. Here it is:</p>
<p><code></code></p>
<p>	var pager = new Pager('panel', 10);<br />
	pager.init();<br />
	pager.showPageNav('pager', 'pageNavPosition', 1);<br />
	pager.showPage(1);</p>
<p></p>
<p><code><br />
function Pager(tableName, itemsPerPage) {<br />
    this.tableName = tableName;<br />
    this.itemsPerPage = itemsPerPage;<br />
    this.currentPage = 1;<br />
    this.pages = 0;<br />
    this.inited = false;<br />
    this.positionId = '';<br />
    this.pageName = '';</code></p>
<p>    this.showRecords = function(from, to) {<br />
        var rows = document.getElementById(tableName).rows;<br />
        // i starts from 1 to skip table header row<br />
        for (var i = 1; i &lt; rows.length; i  ) {<br />
            if (i  to)<br />
                rows[i].style.display = 'none';<br />
            else<br />
                rows[i].style.display = '';<br />
        }<br />
    }</p>
<p>    this.showPage = function(pageNumber) {<br />
    	if (! this.inited) {<br />
    		alert("not inited");<br />
    		return;<br />
    	}</p>
<p>        var oldPageAnchor = document.getElementById('pg' this.currentPage);<br />
        oldPageAnchor.className = 'pg-normal';</p>
<p>        this.currentPage = pageNumber;<br />
        var newPageAnchor = document.getElementById('pg' this.currentPage);<br />
        newPageAnchor.className = 'pg-selected';</p>
<p>        var from = (pageNumber - 1) * itemsPerPage   1;<br />
        var to = from   itemsPerPage - 1;<br />
        this.showRecords(from, to);</p>
<p>        if (pageNumber == 1) {<br />
        	document.getElementById('prev').style.display = 'none';<br />
        } else {<br />
        	document.getElementById('prev').style.display = 'block';<br />
        }</p>
<p>        if (pageNumber == this.pages) {<br />
        	document.getElementById('next').style.display = 'none';<br />
        } else {<br />
        	document.getElementById('next').style.display = 'block';<br />
        }</p>
<p>        this.showPageNav(this.pageName, this.positionId, pageNumber);<br />
    }   </p>
<p>    this.prev = function() {<br />
        if (this.currentPage &gt; 1) {<br />
            this.showPage(this.currentPage - 1);<br />
            this.showPageNav(this.pageName, this.positionId, this.currentPage);<br />
        }<br />
    }</p>
<p>    this.next = function() {<br />
        if (this.currentPage &lt; this.pages) {<br />
            this.showPage(this.currentPage   1);<br />
            this.showPageNav(this.pageName, this.positionId, this.currentPage);<br />
        }<br />
    }                        </p>
<p>    this.init = function() {<br />
        var rows = document.getElementById(tableName).rows;<br />
        var records = (rows.length - 1);<br />
        this.pages = Math.ceil(records / itemsPerPage);<br />
        this.inited = true;<br />
    }</p>
<p>    this.showPageNav = function(pagerName, positionId, position) {<br />
    	if (!this.inited) {<br />
    		alert(&quot;not inited&quot;);<br />
    		return;<br />
    	}<br />
    	this.pageName = pagerName;<br />
    	this.positionId = positionId;</p>
<p>    	var pagerHtml = &#039; &amp;#171 Prev  | ';<br />
    	if (position &gt; 6) {<br />
    		pagerHtml  = '... | ';<br />
    	}<br />
    	for (var page = (position - 5 &gt; 0 ? position - 5 : 1); page  this.pages ? this.pages : position   6);  page  ) {<br />
            pagerHtml  = ''   page   ' | ';<br />
    	}<br />
    	if (position   5 &lt; this.pages) {<br />
    		pagerHtml  = &#039;... | &#039;;<br />
    	}<br />
        pagerHtml  = &#039; Next &#187;';            </p>
<p>        document.getElementById(positionId).innerHTML = pagerHtml;<br />
    }<br />
}<br />
</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shoommese</title>
		<link>http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/comment-page-3/#comment-490267</link>
		<dc:creator>shoommese</dc:creator>
		<pubDate>Mon, 27 Jun 2011 17:31:20 +0000</pubDate>
		<guid isPermaLink="false">http://it.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/#comment-490267</guid>
		<description>Many thanks.</description>
		<content:encoded><![CDATA[<p>Many thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tealAcutt</title>
		<link>http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/comment-page-3/#comment-484659</link>
		<dc:creator>tealAcutt</dc:creator>
		<pubDate>Sat, 11 Jun 2011 18:41:26 +0000</pubDate>
		<guid isPermaLink="false">http://it.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/#comment-484659</guid>
		<description>Hi nice post you have going here.</description>
		<content:encoded><![CDATA[<p>Hi nice post you have going here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Samarjit Roy</title>
		<link>http://en.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/comment-page-2/#comment-476564</link>
		<dc:creator>Samarjit Roy</dc:creator>
		<pubDate>Thu, 19 May 2011 10:41:01 +0000</pubDate>
		<guid isPermaLink="false">http://it.newinstance.it/2006/09/27/client-side-html-table-pagination-with-javascript/#comment-476564</guid>
		<description>Hey your code was great, I had modified the Script to show First page and Last page direct links, hope you don&#039;t mind.

And please let me know If I use your work, how may I attribute it to you. Will mentioning you blog name be good enough ?</description>
		<content:encoded><![CDATA[<p>Hey your code was great, I had modified the Script to show First page and Last page direct links, hope you don&#8217;t mind.</p>
<p>And please let me know If I use your work, how may I attribute it to you. Will mentioning you blog name be good enough ?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

