Demo | Source code for Download
Refer page: http://papermashup.com/easy-php-pagination/
<script language = "javascript">
function check(pagenum, totalpage){
for(var i=0;i<=totalpage;i++){
if(i==pagenum)
document.getElementById('page'+pagenum).style.border='1px solid #000000';
else
document.getElementById('page'+i).style.border='0px solid #000000';
}
}
</script>
<%= javascript_include_tag "prototype" %>
<%
@articles = Article.find(:all, :limit => 10)
@allarticles = Article.find(:all)
@total = @allarticles.length/10
for x in 0..@total
@num = x+1
%>
<span id="page<%=x%>" onclick="check(<%=x%>,<%=@total%>)">
<%= link_to_remote @num, :url => { :action => "articles_per_page", :id => x },
:update => "article_list" %>
</span>
<% end %>
<div id = 'article_list'>
<%= render :partial => 'article', :collection => @articles %>
</div>
Title: <%= article.title %><br>
Author: <%= article.author %>
<hr>
def articles_per_page
@show = ((params[:id].to_i)*10)
@articles = Article.find(:all, :offset => @show, :limit => 10)
render :partial => 'article', :collection => @articles
end