没有明白。 这个是我选择每页多少行的语句: <span><B>每页显示:</B> <input type="text" style="width=40" value="10" name="page" id="pagesize"> <input type="button" value="确定" onclick="changePageSize();"> </span>下面是我分页时动态传参数的语句: String rows=request.getParameter("page"); int record_per_page=Integer.parseInt(rows); //每页显示的记录数 int firstrecord_everypage=0; //当前页面所显示的第一条记录的索引下面是我的查询语句: String sql = "select RecvAccount,SenderAccount,RecvTime,MailTheme from TabGmailInbox order by RecvTime limit "+firstrecord_everypage+","+record_per_page+"";请问问题出在哪里呢?你说的回发触发,麻烦你再仔细一点解释一下好不好?谢谢谢谢
你把前台 pagesize的值,传到后台去,再有String rows=request.getParameter("page"); int record_per_page=Integer.parseInt(rows); //每页显示的记录数 int firstrecord_everypage=0; //当前页面所显示的第一条记录的索引 这个接收,然后查询,这样有问题吗?
//以下代码实现分页,主要思路是输入一个页码,对应的行style.display='',其余行='none' var pagesize=10; var totalrecno=document.getElementById("show").rows.length-1; var currentpageno=1; var totalpage=totalrecno%pagesize==0?(parseInt(totalrecno/pagesize)):(parseInt(totalrecno/pagesize+1)); function ppage() { if(currentpageno==1) { } else { currentpageno=currentpageno-1; alterpage(currentpageno); } } function npage() { if(currentpageno==totalpage) { } else { currentpageno=currentpageno+1; alterpage(currentpageno); } } function spage() { var pageno=document.getElementById("pageNo").value; alterpage(pageno);
} function alterpage(pageno)//核心 { var mytable=document.getElementById("show"); mytable.rows[0].display=''; var i=((pageno-1)*pagesize+1); for(var j=1;j<i;j++) { mytable.rows[j].style.display='none'; } for(;i<=pageno*pagesize&&i<=totalrecno;i++) { mytable.rows[i].style.display=''; } for(;i<=totalrecno;i++) { mytable.rows[i].style.display='none'; } }
//以下代码实现分页,主要思路是输入一个页码,对应的行style.display='',其余行='none' var pagesize=10; var totalrecno=document.getElementById("show").rows.length-1; var currentpageno=1; var totalpage=totalrecno%pagesize==0?(parseInt(totalrecno/pagesize)):(parseInt(totalrecno/pagesize+1)); function ppage() { if(currentpageno==1) { } else { currentpageno=currentpageno-1; alterpage(currentpageno); } } function npage() { if(currentpageno==totalpage) { } else { currentpageno=currentpageno+1; alterpage(currentpageno); } } function spage() { var pageno=document.getElementById("pageNo").value; alterpage(pageno);
} function alterpage(pageno)//核心 { var mytable=document.getElementById("show"); mytable.rows[0].display=''; var i=((pageno-1)*pagesize+1); for(var j=1;j<i;j++) { mytable.rows[j].style.display='none'; } for(;i<=pageno*pagesize&&i<=totalrecno;i++) { mytable.rows[i].style.display=''; } for(;i<=totalrecno;i++) { mytable.rows[i].style.display='none'; } }
<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312">
<head>
<title>JS静态分页程序</title>
</head>
<style type="text/css">
a:link,a:visited,a:hover,.current,#info{
border:1px solid #DDD;
background:#F2F2F2;
display:inline-block;
margin:1px;
text-decoration:none;
font-size:12px;
width:15px;
height:15px;
text-align:center;
line-height:15px;
color:#AAA;
padding:1px 2px;
}
a:hover{
border:1px solid #E5E5E5;
background:#F9F9F9;
}
.current{
border:1px solid #83E7E4;
background:#DFF9F8;
margin:1px;
color:#27CBC7;
}
#info{
width:auto;
}
</style>
<body>
<div id="setpage"></div>
<script type="text/javascript">
<!--
var totalpage,pagesize,cpage,count,curcount,outstr;
//初始化
cpage = 1;
totalpage = 56;
pagesize = 10;
outstr = "";
function gotopage(target)
{
cpage = target; //把页面计数定位到第几页
setpage();
//reloadpage(target); //调用显示页面函数显示第几页,这个功能是用在页面内容用ajax载入的情况
}
function setpage()
{
if(totalpage<=10){ //总页数小于十页
for (count=1;count<=totalpage;count++)
{ if(count!=cpage)
{
outstr = outstr + "<a href='javascript:void(0)' onclick='gotopage("+count+")'>"+count+"</a>";
}else{
outstr = outstr + "<span class='current' >"+count+"</span>";
}
}
}
if(totalpage>10){ //总页数大于十页
if(parseInt((cpage-1)/10) == 0)
{
for (count=1;count<=10;count++)
{ if(count!=cpage)
{
outstr = outstr + "<a href='javascript:void(0)' onclick='gotopage("+count+")'>"+count+"</a>";
}else{
outstr = outstr + "<span class='current'>"+count+"</span>";
}
}
outstr = outstr + "<a href='javascript:void(0)' onclick='gotopage("+count+")'> next </a>";
}
else if(parseInt((cpage-1)/10) == parseInt(totalpage/10))
{
outstr = outstr + "<a href='javascript:void(0)' onclick='gotopage("+(parseInt((cpage-1)/10)*10)+")'>previous</a>";
for (count=parseInt(totalpage/10)*10+1;count<=totalpage;count++)
{ if(count!=cpage)
{
outstr = outstr + "<a href='javascript:void(0)' onclick='gotopage("+count+")'>"+count+"</a>";
}else{
outstr = outstr + "<span class='current'>"+count+"</span>";
}
}
}
else
{
outstr = outstr + "<a href='javascript:void(0)' onclick='gotopage("+(parseInt((cpage-1)/10)*10)+")'>previous</a>";
for (count=parseInt((cpage-1)/10)*10+1;count<=parseInt((cpage-1)/10)*10+10;count++)
{
if(count!=cpage)
{
outstr = outstr + "<a href='javascript:void(0)' onclick='gotopage("+count+")'>"+count+"</a>";
}else{
outstr = outstr + "<span class='current'>"+count+"</span>";
}
}
outstr = outstr + "<a href='javascript:void(0)' onclick='gotopage("+count+")'> next </a>";
}
}
document.getElementById("setpage").innerHTML = "<div id='setpage'><span id='info'>共"+totalpage+"页|第"+cpage+"页<\/span>" + outstr + "<\/div>";
outstr = "";
}
setpage(); //调用分页
//-->
</script>
</body>
</html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>表格分页显示</title></head><body>
<script language="javascript">
<!--
var pageSize=4,currentPageNum=1,totlePageNum
var obj,totleRows,totleCols
var rowHeigth = 20;
var obj;
function begin(){
obj=document.getElementById('tab1').rows ;
totleRows=obj.length;
totleCols=document.getElementById('tab1').rows(0).cells.length;
totlePageNum=Math.ceil((totleRows-1)/pageSize)
//如果某一页行数小于pageSize,则增加空行
if(totleRows==0 || (totleRows-1)%pageSize != 0){
var tempCols
if(totleRows==0)
tempCols = totleCols;
else tempCols = pageSize-(totleRows-1)%pageSize;
for(i=0;i<tempCols;i++){
var newBlankRow = document.getElementById('tab1').insertRow();
var point = newBlankRow.rowIndex;
for (m=0; m < totleCols; m++) {
obj[point].insertCell();
obj[point].cells(m).innerHTML = " ";
}
}
totleRows = document.getElementById('tab1').rows.length;
} N(0);
}function resetStyle(){
for (var i=1;i<totleRows;i++)obj[i].style.display="none"
}
function N(k){
if (k>0 && currentPageNum>=totlePageNum ||k<0 && currentPageNum<=1)return;
currentPageNum+=k;
resetStyle();
toPage(currentPageNum);
filter(currentPageNum);
}
function firstOrLast(flag){
if(flag==0)
currentPageNum = 1;
else if(flag==1)
currentPageNum = totlePageNum;
else
return ;
resetStyle();
toPage(currentPageNum);
filter(currentPageNum);}
function toPage(currentPageNum){
for (var i=(currentPageNum-1)*pageSize+1;i<=currentPageNum*pageSize;i++)
obj[i].style.display="";
}function filter(currentPageNum){
//如果是第一页,则“上一页”不可用
if(currentPageNum-1<1) {
document.getElementById("back").disabled=true;
document.getElementById("first").disabled=true;
}
else{
document.getElementById("back").disabled=false;
document.getElementById("first").disabled=false;
}
//如果是最后一页,则"下一页"不可用
if(currentPageNum+1>totlePageNum ) {
document.getElementById("next").disabled=true;
document.getElementById("last").disabled=true;
}
else{
document.getElementById("next").disabled=false;
document.getElementById("last").disabled=false;
}
}
function changePageSize(){
pageSize = document.getElementById('pagesize').value ;
begin();
}
//-->
</script><input type=text value=4 id=pagesize>
<input type=button value="确定" onclick="changePageSize();">
<div id="divTable">
<table border="1" cellpadding="0" cellspacing="0" id="tab1">
<tbody><tr>
<td width="73"> 序号</td>
<td width="223"> 标题</td>
<td width=80> 作者</td>
<td width=100> 发表时间</td></tr><tr height="20">
<td width="73">00</td>
<td width="223" align="left"><a href="###">00</a></td>
<td width=80>00</td>
<td width=100>00</td></tr><tr height="20">
<td width="73">11</td>
<td width="223" align="left"><a href="###">11</a></td>
<td width=80>11</td>
<td width=100>11</td></tr><tr height="20">
<td width="73">22</td>
<td width="223" align="left"><a href="###">22</a></td>
<td width=80>22</td>
<td width=100>22</td></tr><tr height="20">
<td width="73">33</td>
<td width="223" align="left"><a href="###">33</a></td>
<td width=80>33</td>
<td width=100>33</td></tr><tr height="20">
<td width="73">44</td>
<td width="223" align="left"><a href="###">44</a></td>
<td width=80>44</td>
<td width=100>44</td></tr><tr height="20">
<td width="73">55</td>
<td width="223" align="left"><a href="###">55</a></td>
<td width=80>55</td>
<td width=100>55</td></tr><tr height="20">
<td width="73">66</td>
<td width="223" align="left"><a href="###">66</a></td>
<td width=80>66</td>
<td width=100>66</td></tr><tr height="20">
<td width="73">77</td>
<td width="223" align="left"><a href="###">77</a></td>
<td width=80>77</td>
<td width=100>77</td></tr><tr height="20">
<td width="73">88</td>
<td width="223" align="left"><a href="###">88</a></td>
<td width=80>88</td>
<td width=100>88</td></tr><tr height="20">
<td width="73">99</td>
<td width="223" align="left"><a href="###">99</a></td>
<td width=80>99</td>
<td width=100>99</td></tr>
</table>
</div>
<br>
<input id="first" type=button value="第一页" onclick="firstOrLast(0)">
<input id="back" type=button value="上一页" onclick="N(-1)">
<input id="next" type=button value="下一页" onclick="N(1)">
<input id="last" type=button value="最后一页" onclick="firstOrLast(1)"><script language="JavaScript">
<!--begin() ;
//-->
</script></body></html>
这个是我选择每页多少行的语句:
<span><B>每页显示:</B>
<input type="text" style="width=40" value="10" name="page" id="pagesize">
<input type="button" value="确定" onclick="changePageSize();">
</span>下面是我分页时动态传参数的语句: String rows=request.getParameter("page");
int record_per_page=Integer.parseInt(rows); //每页显示的记录数
int firstrecord_everypage=0; //当前页面所显示的第一条记录的索引下面是我的查询语句:
String sql = "select RecvAccount,SenderAccount,RecvTime,MailTheme from TabGmailInbox order by RecvTime limit "+firstrecord_everypage+","+record_per_page+"";请问问题出在哪里呢?你说的回发触发,麻烦你再仔细一点解释一下好不好?谢谢谢谢
pagesize的值,传到后台去,再有String rows=request.getParameter("page");
int record_per_page=Integer.parseInt(rows); //每页显示的记录数
int firstrecord_everypage=0; //当前页面所显示的第一条记录的索引
这个接收,然后查询,这样有问题吗?
是的。这样的话整个表格就不显示了。包括表头。请问我request.getParameter("page")是不是必须要先跳转到下一个页面才有效呢? 我的这个语句是加在本页面的。。
你到多少没有
var pagesize=10;
var totalrecno=document.getElementById("show").rows.length-1;
var currentpageno=1;
var totalpage=totalrecno%pagesize==0?(parseInt(totalrecno/pagesize)):(parseInt(totalrecno/pagesize+1));
function ppage()
{
if(currentpageno==1)
{
}
else
{
currentpageno=currentpageno-1;
alterpage(currentpageno);
}
}
function npage()
{
if(currentpageno==totalpage)
{
}
else
{
currentpageno=currentpageno+1;
alterpage(currentpageno);
}
}
function spage()
{
var pageno=document.getElementById("pageNo").value;
alterpage(pageno);
}
function alterpage(pageno)//核心
{
var mytable=document.getElementById("show");
mytable.rows[0].display='';
var i=((pageno-1)*pagesize+1);
for(var j=1;j<i;j++)
{
mytable.rows[j].style.display='none';
}
for(;i<=pageno*pagesize&&i<=totalrecno;i++)
{
mytable.rows[i].style.display='';
}
for(;i<=totalrecno;i++)
{
mytable.rows[i].style.display='none';
}
}
//以下代码实现分页,主要思路是输入一个页码,对应的行style.display='',其余行='none'
var pagesize=10;
var totalrecno=document.getElementById("show").rows.length-1;
var currentpageno=1;
var totalpage=totalrecno%pagesize==0?(parseInt(totalrecno/pagesize)):(parseInt(totalrecno/pagesize+1));
function ppage()
{
if(currentpageno==1)
{
}
else
{
currentpageno=currentpageno-1;
alterpage(currentpageno);
}
}
function npage()
{
if(currentpageno==totalpage)
{
}
else
{
currentpageno=currentpageno+1;
alterpage(currentpageno);
}
}
function spage()
{
var pageno=document.getElementById("pageNo").value;
alterpage(pageno);
}
function alterpage(pageno)//核心
{
var mytable=document.getElementById("show");
mytable.rows[0].display='';
var i=((pageno-1)*pagesize+1);
for(var j=1;j<i;j++)
{
mytable.rows[j].style.display='none';
}
for(;i<=pageno*pagesize&&i<=totalrecno;i++)
{
mytable.rows[i].style.display='';
}
for(;i<=totalrecno;i++)
{
mytable.rows[i].style.display='none';
}
}