❶ jquery.pagination.js 如何用
1,下载3个文件
分别为:jquery-1.7.1.js、jquery.pagination.js、pagination.css
//详见附件
2,准备好服务器端返回结果
主要代码如下:
Php代码
$members = array(array().......); //详见附件
$total = count($members);
$pageIndex = $_POST['pageIndex'];
$items_per_page = $_POST['items_per_page'];
$result = array();
$start = $pageIndex * $items_per_page;
$end = ($pageIndex+1) * $items_per_page;
if($end > $total){$end = $total;}
for($i = $start; $i < $end; $i++){
$result[] = $members[$i];
}
print json_encode(array('total'=>$total,'result'=>$result));
3,前端js代码(核心)
Js代码
var items_per_page = 3;
var page_index = 0;
function getDataList(index){
var pageIndex = index;
$.ajax({
type: "POST",
url: "members.php",
data: "pageIndex="+pageIndex+'&items_per_page='+items_per_page,
dataType: 'json',
contentType: "application/x-www-form-urlencoded",
success: function(msg){
var total = msg.total;
var html = '<table><tr><th>姓名</th><th>工作时间</th><th>籍贯</th><th>职务</th><th>生卒年</th><th>操作</th></tr>';
$.each(msg.result,function(i,n){
html += '<tr><td>'+n[0]+'</td><td>'+n[1]+'</td><td>'+n[2]+'</td><td>'+n[3]+'</td><td>'+n[4]+'</td>'
html += '<td><a href=#>删除</a></td></tr>';
});
html += '</table>';
$('#Searchresult').html(html);
//分页-只初始化一次
if($("#Pagination").html().length == ''){
$("#Pagination").pagination(total, {
'items_per_page' : items_per_page,
'num_display_entries' : 10,
'num_edge_entries' : 2,
'prev_text' : "上一页",
'next_text' : "下一页",
'callback' : pageselectCallback
});
}
}
});
}
function pageselectCallback(page_index, jq){
getDataList(page_index);
}
$(document).ready(function(){
getDataList(page_index);
});
4,前端html
Html代码
<dl id="Searchresult">
<dt>Search Results will be inserted here ...</dt>
</dl>
<br style="clear:both;" />
<div id="Pagination" class="pagination"></div>
<br style="clear:both;" />
批注:
(1)jquery.js和jquery.pagination.js插件的加载有先后顺序,不能颠倒。特别是在复杂的页面中。
(2)jquery.pagination.js实现可以有很多种。不同的分页插件,使用时可能会有差别,所以最好有足够的js功底,读懂那些插件是如何实现,以及如何引用。
(3)pagination.css是样式,可以独立出来。也即可以使用很多种不同的样式修饰,不必是给出的那一个。
❷ JS 前端的筛选代码
我特么的终于写出来了,,给大家拿去用用看,自己添加css样式。我感觉头发要掉了。
粗略的样子就是这样,后面是代码。
//JavaScriptDocument
//JavaScriptDocument
/*!jQueryv2.1.4|(c)2005,2015jQueryFoundation,Inc.|jquery.org/license*/
$(document).ready(function(){
$(".uox").click(function(){
$(".uox-1").show(500);
$(".uos-1").hide(500);
$(".box-1").hide(500);
$(".jod-1").hide(500);
$(".sor-1").hide(500);
$("#page").hide(500);
});
$(".uos").click(function(){
$(".uos-1").show(500);
$(".uox-1").hide(500);
$(".box-1").hide(500);
$(".jod-1").hide(500);
$(".sor-1").hide(500);
$("#page").hide(500);
});
$(".box").click(function(){
$(".box-1").show(500);
$(".uos-1").hide(500);
$(".uox-1").hide(500);
$(".jod-1").hide(500);
$(".sor-1").hide(500);
$("#page").hide(500);
});
$(".jod").click(function(){
$(".jod-1").show(500);
$(".uos-1").hide(500);
$(".box-1").hide(500);
$(".uox-1").hide(500);
$(".sor-1").hide(500);
$("#page").hide(500);
});
$(".sor").click(function(){
$(".sor-1").show(500);
$(".uos-1").hide(500);
$(".box-1").hide(500);
$(".jod-1").hide(500);
$(".uox-1").hide(500);
$("#page").hide(500);
});
//第一组筛选结束
//开始第二组筛选
$(".newch").click(function(){
$(".newch-1").show(500);
$(".bopch-1").hide(500);
$(".luoch-1").hide(500);
$(".dizch-1").hide(500);
$(".dnych-1").hide(500);
$(".ousch-1").hide(500);
$(".tiych-1").hide(500);
$(".getch-1").hide();
$("#page").hide(500);
});
$(".luoch").click(function(){
$(".luoch-1").show(500);
$(".newch-1").hide(500);
$(".bopch-1").hide(500);
$(".dizch-1").hide(500);
$(".dnych-1").hide(500);
$(".ousch-1").hide(500);
$(".tiych-1").hide(500);
$(".getch-1").hide();
$("#page").hide(500);
});
$(".bopch").click(function(){
$(".bopch-1").show(500);
$(".newch-1").hide(500);
$(".dizch-1").hide(500);
$(".dnych-1").hide(500);
$(".luoch-1").hide(500);
$(".ousch-1").hide(500);
$(".tiych-1").hide(500);
$(".getch-1").hide(500);
$("#page").hide(500);
});
$(".dizch").click(function(){
$(".dizch-1").show(500);
$(".bopch-1").hide(500);
$(".newch-1").hide(500);
$(".luoch-1").hide(500);
$(".dnych-1").hide(500);
$(".ousch-1").hide(500);
$(".tiych-1").hide(500);
$(".getch-1").hide(500);
$("#page").hide(500);
});
$(".dnych").click(function(){
$(".dnych-1").show(500);
$(".bopch-1").hide(500);
$(".dizch-1").hide(500);
$(".luoch-1").hide(500);
$(".newch-1").hide(500);
$(".ousch-1").hide(500);
$(".tiych-1").hide(500);
$(".getch-1").hide(500);
$("#page").hide(500);
});
$(".ousch").click(function(){
$(".ousch-1").show(500);
$(".bopch-1").hide(500);
$(".dizch-1").hide(500);
$(".luoch-1").hide(500);
$(".dnych-1").hide(500);
$(".newch-1").hide(500);
$(".tiych-1").hide(500);
$(".getch-1").hide(500);
$("#page").hide(500);
});
$(".tiych").click(function(){
$(".tiych-1").show(500);
$(".bopch-1").hide(500);
$(".dizch-1").hide(500);
$(".luoch-1").hide(500);
$(".dnych-1").hide(500);
$(".ousch-1").hide(500);
$(".newch-1").hide(500);
$(".getch-1").hide(500);
$("#page").hide(500);
});
$(".getch").click(function(){
$(".getch-1").show(500);
$(".bopch-1").hide(500);
$(".luoch-1").hide(500);
$(".dizch-1").hide(500);
$(".dnych-1").hide(500);
$(".ousch-1").hide(500);
$(".tiych-1").hide(500);
$(".newch-1").hide(500);
$("#page").hide(500);
});
//第二组结束
//第三组筛选
$(".wan-10").click(function(){
$(".wan-sh").show(500);
$(".wan-es").hide(500);
$(".wan-ss").hide(500);
$(".wan-ws").hide(500);
$(".wan-bs").hide(500);
$(".wan-yb").hide(500);
$(".wan-oth").hide(500);
});
$(".wan-20").click(function(){
$(".wan-es").show(500);
$(".wan-sh").hide(500);
$(".wan-ss").hide(500);
$(".wan-ws").hide(500);
$(".wan-bs").hide(500);
$(".wan-yb").hide(500);
$(".wan-oth").hide(500);
});
$(".wan-30").click(function(){
$(".wan-ss").show(500);
$(".wan-es").hide(500);
$(".wan-sh").hide(500);
$(".wan-ws").hide(500);
$(".wan-bs").hide(500);
$(".wan-yb").hide(500);
$(".wan-oth").hide(500);
});
$(".wan-50").click(function(){
$(".wan-ws").show(500);
$(".wan-es").hide(500);
$(".wan-ss").hide(500);
$(".wan-sh").hide(500);
$(".wan-bs").hide(500);
$(".wan-yb").hide(500);
$(".wan-oth").hide(500);
});
$(".wan-80").click(function(){
$(".wan-bs").show(500);
$(".wan-es").hide(500);
$(".wan-ss").hide(500);
$(".wan-ws").hide(500);
$(".wan-sh").hide(500);
$(".wan-yb").hide(500);
$(".wan-oth").hide(500);
});
$(".wan-100").click(function(){
$(".wan-yb").show(500);
$(".wan-es").hide(500);
$(".wan-ss").hide(500);
$(".wan-ws").hide(500);
$(".wan-bs").hide(500);
$(".wan-sh").hide(500);
$(".wan-oth").hide(500);
});
$(".wan-ot").click(function(){
$(".wan-oth").show(500);
$(".wan-es").hide(500);
$(".wan-ss").hide(500);
$(".wan-ws").hide(500);
$(".wan-bs").hide(500);
$(".wan-yb").hide(500);
$(".wan-sh").hide(500);
});
//第三组结束
//全部==按钮
$(".qos").click(function(){
$("*").show(500);
$(".uio").show(500);
$(".uip").show(500);
$("#page").hide();
});
$(".zhan").click(function(){
$("#page").slideToggle(500);
});
$(".hons").click(function(){
$("*").toggleClass("red");
});
//变色(红色)
$(".newsli").first().css("color","#5A0305");
$(".newsa").first().css("color","#5A0305");
$(".newsli").eq(1).css("color","#C0832C");
$(".newsa").eq(1).css("color","#C0832C");
$(".newsli").eq(2).css("color","#12B4B7");
$(".newsa").eq(2).css("color","#12B4B7");
$(".newsli").eq(3).css("color","#000");
$(".newsli").eq(4).css("color","#000");
$(".newsli").eq(5).css("color","#000");
$(".newsli").eq(6).css("color","#000");
$(".newsli").eq(7).css("color","#000");
$(".newsli").eq(8).css("color","#000");
$(".newsli").eq(9).css("color","#000");
//获取外部文件代码
$(".huoq").click(function(){
$("#div1").load("../DW+GY/css/loud.htm");
});
});
❸ 网页上的“上一页,下一页”JS代码怎么写
需要准备的材料分别有:电脑、html编辑器、浏览器。
1、首先,打开html编辑器,新建html文件,例如:index.html。
❹ js的分页原理以及实现步骤是什么
主要是借鉴了网上一个例子,修改了一些小地方,前端分页的技巧,表格的数据是已经写好了,可以前端渲染表格然后再分页,都是可以的。
其实分页最关键是这两句:
var startRow = (currentPage - 1) * pageSize+1; //currentPage 为当前页,pageSize为每页显示的数据量
var endRow = currentPage * pageSize;
找到我们需要显示的行的范围(starRow~endRow)
ps:这里在跳转的时候遇到了一个小BUG,就是获取到的select的value值是string类型的,比如获取到了1,然后你想再加1的时候就会变成"11" 而不是我们想要的"2",所以这里需要用parseInt( )来转换一下,小细节需要注意呀!!!
效果图:
[javascript] view plain print?
<!doctypehtml>
<html>
<head>
<metacharset='utf-8'>
<styletype="text/css">
a{
text-decoration:none;
}
.table2{
border:#C8C8C8solid;
border-width:1px0px0px1px;
background:#F3F0F0;
margin-top:25px;
}
.td0{
border:#C8C8C8solid;
border-width:001px0;
}
.td2{
border:#C8C8C8solid;
border-width:01px1px0;
}
.barcon{
width:1000px;
margin:0auto;
text-align:center;
}
.barcon1{
font-size:17px;
float:left;
margin-top:20px;
}
.barcon2{
float:right;
}
.barcon2ul{
margin:20px0;
padding-left:0;
list-style:none;
text-align:center;
}
.barcon2li{
display:inline;
}
.barcon2a{
font-size:16px;
font-weight:normal;
display:inline-block;
padding:5px;
padding-top:0;
color:black;
border:1pxsolid#ddd;
background-color:#fff;
}
.barcon2a:hover{
background-color:#eee;
}
.ban{
opacity:.4;
}
</style>
</head>
<body>
<tablewidth="950"cellpadding="0"cellspacing="0"class="table2"align="center">
<thead>
<tr>
<tdcolspan="3"height="33"class="td0"></td>
<tdalign="center"class="td2"><ahref="###">添加用户</a></td>
</tr>
<tralign="center">
<thwidth="150"height="33"class="td2">序号</th>
<thwidth="300"class="td2">用户名</th>
<thwidth="250"class="td2">权限</th>
<thwidth="250"class="td2">操作</th>
</tr>
</thead>
<tbodyid="adminTbody">
<tralign="center">
<tdclass="td2"height="33"width="150">1</td>
<tdclass="td2">admin</td>
<tdclass="td2">管理员</td>
<tdclass="td2"><ahref="###">修改</a></td>
</tr>
</tbody>
</table>
<divid="barcon"class="barcon">
<divid="barcon1"class="barcon1"></div>
<divid="barcon2"class="barcon2">
<ul>
<li><ahref="###"id="firstPage">首页</a></li>
<li><ahref="###"id="prePage">上一页</a></li>
<li><ahref="###"id="nextPage">下一页</a></li>
<li><ahref="###"id="lastPage">尾页</a></li>
<li><selectid="jumpWhere">
</select></li>
<li><ahref="###"id="jumpPage"onclick="jumpPage()">跳转</a></li>
</ul>
</div>
</div>
<scriptsrc="jquery.js"></script>
<script>
/*动态生成用户函数
num为生成的用户数量
*/
functiondynamicAddUser(num){
for(vari=1;i<=num;i++)
{
vartrNode=document.createElement("tr");
$(trNode).attr("align","center");
//序号
vartdNodeNum=document.createElement("td");
$(tdNodeNum).html(i+1);
tdNodeNum.style.width="150px";
tdNodeNum.style.height="33px";
tdNodeNum.className="td2";
//用户名
vartdNodeName=document.createElement("td");
$(tdNodeName).html("lzj"+i);
tdNodeName.style.width="300px";
tdNodeName.className="td2";
//权限
vartdNodePri=document.createElement("td");
tdNodePri.style.width="250px";
tdNodePri.className="td2";
varpriText=document.createElement("span");
$(priText).css({"display":"inline-block","text-align":"center"});
$(priText).text("普通用户");
tdNodePri.appendChild(priText);
//操作
vartdNodeOper=document.createElement("td");
tdNodeOper.style.width="170px";
tdNodeOper.className="td2";
vareditA=document.createElement("a");
$(editA).attr("href","###").text("编辑");
$(editA).css({display:"inline-block"});
tdNodeOper.appendChild(editA);
trNode.appendChild(tdNodeNum);
trNode.appendChild(tdNodeName);
trNode.appendChild(tdNodePri);
trNode.appendChild(tdNodeOper);
$("#adminTbody")[0].appendChild(trNode);
}
}
$(function(){
dynamicAddUser(80);
goPage(1,10);
vartempOption="";
for(vari=1;i<=totalPage;i++)
{
tempOption+='<optionvalue='+i+'>'+i+'</option>'
}
$("#jumpWhere").html(tempOption);
})
/**
*分页函数
*pno--页数
*psize--每页显示记录数
*分页部分是从真实数据行开始,因而存在加减某个常数,以确定真正的记录数
*纯js分页实质是数据行全部加载,通过是否显示属性完成分页功能
**/
varpageSize=0;//每页显示行数
varcurrentPage_=1;//当前页全局变量,用于跳转时判断是否在相同页,在就不跳,否则跳转。
vartotalPage;//总页数
functiongoPage(pno,psize){
varitable=document.getElementById("adminTbody");
varnum=itable.rows.length;//表格所有行数(所有记录数)
pageSize=psize;//每页显示行数
//总共分几页
if(num/pageSize>parseInt(num/pageSize)){
totalPage=parseInt(num/pageSize)+1;
}else{
totalPage=parseInt(num/pageSize);
}
varcurrentPage=pno;//当前页数
currentPage_=currentPage;
varstartRow=(currentPage-1)*pageSize+1;
varendRow=currentPage*pageSize;
endRow=(endRow>num)?num:endRow;
//遍历显示数据实现分页
/*for(vari=1;i<(num+1);i++){
varirow=itable.rows[i-1];
if(i>=startRow&&i<=endRow){
irow.style.display="";
}else{
irow.style.display="none";
}
}*/
$("#adminTbodytr").hide();
for(vari=startRow-1;i<endRow;i++)
{
$("#adminTbodytr").eq(i).show();
}
vartempStr="共"+num+"条记录分"+totalPage+"页当前第"+currentPage+"页";
document.getElementById("barcon1").innerHTML=tempStr;
if(currentPage>1){
$("#firstPage").on("click",function(){
goPage(1,psize);
}).removeClass("ban");
$("#prePage").on("click",function(){
goPage(currentPage-1,psize);
}).removeClass("ban");
}else{
$("#firstPage").off("click").addClass("ban");
$("#prePage").off("click").addClass("ban");
}
if(currentPage<totalPage){
$("#nextPage").on("click",function(){
goPage(currentPage+1,psize);
}).removeClass("ban")
$("#lastPage").on("click",function(){
goPage(totalPage,psize);
}).removeClass("ban")
}else{
$("#nextPage").off("click").addClass("ban");
$("#lastPage").off("click").addClass("ban");
}
$("#jumpWhere").val(currentPage);
}
functionjumpPage()
{
varnum=parseInt($("#jumpWhere").val());
if(num!=currentPage_)
{
goPage(num,pageSize);
}
}
</script>
</body>
</html>
❺ 怎样用JS等前端程序对输出的新闻内容进行分页
把整个内容放在一个div里,用滚动条的形式显示所有内容可以么
❻ ExtJs的Combobox采用的前端分页,该怎么做模糊过滤
2.0不熟悉,最直接的是看源代码,看看怎么过滤的,重载必要的代码。
不改代码的话,觉得可以先关闭分页,pageSize=-1,然后过滤,然后再打开分页
❼ angularjs2如何实现分页
先给大家简单介绍angular.js和bootstrap基本概念。AngularJS是一个JavaScript框架。它可通过标签添加到HTML页面。AngularJS通过指令扩展了HTML,且通过表达式绑定数据到HTML。Bootstrap,来自Twitter,是目前最受欢迎的前端框架。Bootstrap是基于HTML、CSS、JAVASCRIPT的,它简洁灵活,使得Web开发更加快捷。最近一直学习Angular.js,在学习过程中也练习了很多的Demo,这里先贴一下表格+分页。
❽ 用bootstrap的分页符只能做出外观并不能真正分页 如果想要分页 是否需要js文件如果需要 请告诉我把
bootstrap框架自带有分页的样式,你所要做的就是把 服务端的分页写好,前端的js bootstrap已经封装好了。
❾ js前端分页,与后台无数据交互,写一个json 文件然后$.getJSON(),把数据加载过来之后怎么在前端分页
<!DOCTYPEhtml>
<html>
<head>
<metacharset="UTF-8">
<title>分页</title>
<styletype="text/css">
.grid{
width:400px;
}
.table{
width:100%;
text-align:center;
border:outset#efefef;
border-width:1px0px0px1px;
}
.tableth,td{
line-height:30px;
border:solid#efefef;
border-width:0px1px1px0px;
}
.tabletr{
width:100%;
margin:0auto;
border:none;
overflow:hidden;
color:#2981e4;
font:normal12px/100%"微软雅黑","LucidaGrande","LucidaSans",Helvetica,Arial,Sans;
}
.no-content{
text-align:center;
line-height:36px;
color:red;
font:normal16px/100%"微软雅黑","LucidaGrande","LucidaSans",Helvetica,Arial,Sans;
}
.pager{
padding-top:20px;
text-align:right;
line-height:36px;
color:blue;
font:normal12px/100%"微软雅黑","LucidaGrande","LucidaSans",Helvetica,Arial,Sans;
}
.button,.button:visited{
background-color:#EFEFEF;
border:1pxsolid#d5d5d5;
background:#fff;
padding:2px6px;
margin:2px;
text-decoration:none;
cursor:pointer
}
.button:hover{
background-color:#2575cf;
color:#fff;
}
.button:active{
top:1px;
}
.no-page{
background-color:#EFEFEF;
cursor:default;
}
.pagerinput[type='text']{
width:20px;
color:#333;
padding:4px5px;
border:1pxsolid#e0ecff;
border-radius:2px;
-o-border-radius:2px;
-moz-border-radius:2px;
-wekit-border-radius:2px;
box-shadow:0002pxrgba(255,255,255,0.2);
-o-box-shadow:0002pxrgba(255,255,255,0.2);
-webkit-box-shadow:0002pxrgba(255,255,255,0.2);
-moz-box-shadow:0002pxrgba(255,255,255,0.2);
behavior:url(/PIE.htc);
}
.pagerinput[type='text']:focus,.tableinput[type='text']:hover{
border:1pxsolid#3aa2d0;
outline:none;
}
</style>
</head>
<body>
<divclass="grid">
<divid="content">
</div>
<divid="pager">
</div>
</div>
</body>
</html>
<scripttype="text/javascript">
varjsonData=[];
//生成静态数据
functiongetJsonData(size){
vardatas=[];
for(varidx=0;idx<size;idx++){
datas.push({
account:"Account_"+idx,
userName:"用户_"+idx,
gender:(idx%2==1?"男":"女"),
salary:parseInt(Math.random(idx%50)*10000)+5000
});
}
returndatas;
}
//获取当前页数据
functionquery(cur,size){
varbegin=(cur-1)*size;
varend=cur*size;
returnjsonData.slice(begin,end);
}
window.onload=function(){
//获取JSON数据
jsonData=getJsonData(555);
//加载数据
pageTo(10,1);
};
//加载表格
functionpageTo(pageSize,curPage){
vardataSize=jsonData.length;
if(dataSize==0){
content.innerHTML="<spanclass='no-content'>没有查询到任何数据!</span>";
return;
}
vartotalPage=Math.ceil(dataSize/pageSize);
//table
vardatas=query(curPage,pageSize);
varhtml="<h3>员工信息表</h3><tableclass='table'>";
for(varindex=0;index<datas.length;index++){
vardata=datas[index];
html=html+"<tr>";
html=html+"<td>"+(data.account||'')+"</td>";
html=html+"<td>"+(data.userName||'')+"</td>";
html=html+"<td>"+(data.gender||'')+"</td>";
html=html+"<td>"+(data.salary||'')+"</td>";
html=html+"</tr>";
}
html=html+"</table>";
content.innerHTML=html;
//pager
varphtml="<divclass='pager'>";
if(curPage==1){
phtml=phtml+"<ahref='#'class='buttonno-page'>上一页</a>";
}else{
phtml=phtml+"<ahref='#'class='button'onclick='pageTo("+pageSize+","+(curPage-1)+");'>上一页</a>";
}
phtml=phtml+"<inputtype='text'value='"+curPage+"'onkeypress='goto(this,"+pageSize+");'>";
if(curPage==totalPage){
phtml=phtml+"<ahref='#'class='buttonno-page'>下一页</a>";
}else{
phtml=phtml+"<ahref='#'class='button'onclick='pageTo("+pageSize+","+(curPage+1)+");'>下一页</a>";
}
phtml=phtml+" 共"+totalPage+"页,"+dataSize+"条记录</div>";
pager.innerHTML=phtml;
}
//回车跳转,注意控制输入数字:此处未处理
functiongoto(obj,pageSize){
if(event.keyCode==13){
pageTo(pageSize,parseInt(obj.value));
}
}
</script>
大体思路如上
❿ web分页中嵌套分页怎么解决传值丢失 HTTP Status 500 java.lang.NullPointerException
web分页嵌套分页??
可以使用前端分页进行分页,就是假设加载100条数据,但是不显示全部,然后直接存在js变量中,用js进行DOM操作。也可以用直接的插件。
如果是用后台进行分页的,传GET值到后台,比如链接后加&page=10,则后台接受10,然后看你一页多少数据。数据库用limit (page-1)*15 page*15 可以数据库分页(Mysql)其他数据库可以自己去查下语句。