利用javascript处理数据分页前的 参数 处理,在通过ajax提取相应的数据,代码如下(javascript部分代码):
<html> <head> <title></title> <script> var currentPage =1 ; //当前页码 var totalRows = 20 ;//数据库中总行数 var pageSize = 5 ;//规定每页显示行数 var totalPages = totalRows/pageSize ; //总页数 var startRow =0; //数据库起始行 if((totalRows%pageSize)>0){ totalPages++ ; } var html = "<input type='button' value='首页' onclick=doclick('first')>"; html+="<input type='button' value='下一页' onclick=doclick('next')>"; html+="<input type='button' value='上一页' onclick=doclick('previous')>"; html+="<input type='button' value='最后一页' onclick=doclick('last')>" ; function doclick(method){ if(method=="first") { currentPage = 1; startRow = 0 ; alert("currentPage="+currentPage+" startRow="+startRow) }else if(method=="next"){ if (currentPage == totalPages) { return false ; } currentPage++; startRow = (currentPage-1)*pageSize ; alert("currentPage="+currentPage+" startRow="+startRow) }else if(method=="previous"){ if(currentPage == 1){ return false ; } currentPage--; startRow = (currentPage-1)*pageSize ; alert("currentPage="+currentPage+" startRow="+startRow) }else if(method=="last"){ currentPage = totalPages ; startRow = (currentPage-1)*pageSize ; alert("currentPage="+currentPage+" startRow="+startRow) } document.getElementById('a').innerHTML =html ; } function create(){ document.getElementById('a').innerHTML =html ; } </script> </head> <body onload="create();"> <span id='a'></span> </body> </html>