- jiangzhen1984
- 等级: 初级会员
- 性别:
- 文章: 23
- 积分: 92
- 来自: 北京
|
这是我参考别人的分页后
自己写了个跟简单的分页
js 代码
- < html>
-
- < body>
-
- < span id=contents>
- < span id=splitpage>
-
- < script type="text/javascript">
-
- _currentPage = 2;
- _indexContainer = document.all.splitpage;
- _contentContainer = document.all.contents;
- _totalPages = 0;
- (function pageLoad() {
- _indexContainer.innerHTML =pageNo(100,2,10,7).join(" ");
- var str="getR("+3+")";
- goToPage(100, 3, 10,7,str);
- })();
-
-
- function pageNo(counts, currentPage, perPage,showIndex,str) {
- var perPage = perPage ? perPage : 5;
-
- var pages=0;
- pages=counts/perPage+1;
- var pageIndex = [];
-
- if(currentPage==1){
- pageIndex.push("《《 《 ");
- }else{
- var str1="a href=\"javascript:goToPage("+counts+", "+1+", "+perPage+","+showIndex+",'"+str+"')\">《《 a href=\"javascript:goToPage("+counts+", "+(currentPage-1>0?currentPage-1:1)+", "+perPage+","+showIndex+",'"+str+"')\">《 ";
- pageIndex.push(str1);
- }
-
- var cyclCousnts=parseInt(showIndex/2);
-
- for(var i=1;i<=showIndex;i++){
- var tmpPage=currentPage>=cyclCousnts?currentPage-cyclCousnts+i-1:i;
- if(currentPage==tmpPage)
- pageIndex.push("font color=\"red\">"+tmpPage+"");
- else if(tmpPage>pages)
- continue;
- else if(tmpPage<1)
- continue;
- else{
- var str1="a href=\"javascript:goToPage("+counts+", "+tmpPage+", "+perPage+","+showIndex+",'"+str+"')\">"+tmpPage+"";
- pageIndex.push(str1);
- }
- }
- if(currentPage==pages){
- pageIndex.push(" 》 》》");
- }else{
- var str1="a href=\"javascript:goToPage("+counts+", "+(currentPage+1>pages?currentPage:currentPage+1)+", "+perPage+","+showIndex+",'"+str+"')\">》 a href=\"javascript:goToPage("+counts+", "+pages+", "+perPage+","+showIndex+",'"+str+"')\">》》 ";
- pageIndex.push(str1);
- }
-
- return pageIndex;
- }
-
-
- function goToPage(counts, currentPage, perPage,showIndex,str) {
- _contentContainer.innerHTML = eval(str);
- _indexContainer.innerHTML = pageNo(counts, currentPage, perPage,showIndex,str).join(" ");
- }
-
- function getRecord(currentPage){
- return "the current pagaea is:"+currentPage;
- }
-
- function getR(currentPage){
- return "the current page by eval is:"+currentPage;
- }
-
- < /script>
- < /body>
- < /html>
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
返回顶楼 |
|
|
- hgq0011
- 等级:
- 性别:
- 文章: 961
- 积分: 1017
- 来自: 广州
|
能够有一个很好的demo演示吗?
排版能更好一点吗?
|
返回顶楼 |
|
|
- liuzongan
- 等级: 初级会员
- 性别:
- 文章: 103
- 积分: 20
- 来自: 北京
|
怎么显示不出来职?
|
返回顶楼 |
|
|
- 笨笨狗
- 等级:
- 性别:
- 文章: 260
- 积分: 377
- 来自: 昆明
|
ajax分页,可以参考下我的文章:
http://www.iteye.com/topic/79869
实现了三种数据获取方式,利用Prototype框架实现OO对象设计,欢迎指正:)
|
返回顶楼 |
|
|