{dede:memberlist orderby='scores' row='30'}
<tr>
<td width="15" align="center" class="di">·</td>
<td height="22" class="titleld">[field:uname/]</td>
</tr>
{/dede:memberlist}
用js把dedecms的sql标签从数据库中读取的数据进行分页的方法
<table id="loop">
{dede:sql sql="select * from leaveword order by lyid desc"}
<tr class="looptr">
<td class="loop-left-td" valign="top">
<div class="loopdiv">姓名:[field:name/]</div>
<div class="loopdiv">联系电话:[field:phone/]</div>
<div class="loopdiv">Q Q:[field:qq/]</div>
<div class="loopdiv">E-mail:[field:email/]</div>
</td>
<td class="loop-right-td" valign="top">
<div class='lytitle'><strong>留言题目:[field:lytitle/]</strong><span><strong>留言时间:[field:lytime/]</strong></span></div>
<div class='lycontent'><p><strong>留言内容:</strong></p>[field:lycontent/]</div>
<div class='hfcontent'><p><strong>回复:</strong></p><span>[field:hfcontent/]</span></div>
</td>
</tr>
{/dede:sql}
<div id="changpage"></div>
<script language="javascript">
var obj,j;
var page=0;
var nowPage=0;//当前页
var listNum=5;//每页显示<ul>数
var PagesLen;//总页数
var PageNum=4;//分页链接接数(5个)
onload=function(){
obj=document.getElementById("loop").getElementsByTagName("tr");
j=obj.length
PagesLen=Math.ceil(j/listNum);
upPage(0)
}
function upPage(p){
nowPage=p
//内容变换 34
for (var i=0;i<j;i++){
obj.style.display="none"
}
for (var i=p*listNum;i<(p+1)*listNum;i++){
if(obj)obj.style.display="block"
}
strS='<a href="###" onclick="upPage(0)">首页</a> '
var PageNum_2=PageNum%2==0?Math.ceil(PageNum/2)+1:Math.ceil(PageNum/2)
var PageNum_3=PageNum%2==0?Math.ceil(PageNum/2):Math.ceil(PageNum/2)+1
var strC="",startPage,endPage;
if (PageNum>=PagesLen) {startPage=0;endPage=PagesLen-1}
else if (nowPage<PageNum_2){startPage=0;endPage=PagesLen-1>PageNum?PageNum:PagesLen-1}//首页
else {startPage=nowPage+PageNum_3>=PagesLen?PagesLen-PageNum-1: nowPage-PageNum_2+1;var t=startPage+PageNum;endPage=t>PagesLen?PagesLen-1:t}
for (var i=startPage;i<=endPage;i++){
if (i==nowPage)strC+='<a href="###" style="color:red;font-weight:700;" onclick="upPage('+i+')">'+(i+1)+'</a> '
else strC+='<a href="###" onclick="upPage('+i+')">'+(i+1)+'</a> '
}
strE=' <a href="###" onclick="upPage('+(PagesLen-1)+')">尾页</a> '
strE2=nowPage+1+"/"+PagesLen+"页"+" 共"+j+"条"
document
getElementById("changpage").innerHTML=strS+strC+strE+strE2
}
</script>
</table>
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!