日期:2014-05-17  浏览次数:20727 次

怎样获得当前页的页码
使用如下方法:
<TABLE   DATASRC= "#customer "   DATAPAGESIZE=10>
<TR> <TD> <INPUT   TYPE=TEXTBOX   DATAFLD= "customer_name "> </TD> </TR>
</TABLE>
可以使用table.previousPage()和table.nextPage()向前或向后翻页,但是怎么得到当前页的页码

------解决方案--------------------
貌似不能
------解决方案--------------------
<html>
<head>
<script>
function init(){//初始化总页数
var totPage=document.getElementById( 'total ');
totPage.innerText=data.recordset.recordcount;
}

function page(databox,datasrc,moveto){
//databox为table的id,即此例中的oTab
//datasrc为数据源id,即此例中的data
//moveto为翻页方式:firstPage(首页)|previousPage(上页)|nextPage(下页)|lastPage(末页)
var curPage=document.getElementById( 'current ');
switch (moveto){
case 'firstPage ':databox.firstPage();
datasrc.recordset.movefirst();
curPage.innerText=datasrc.recordset.absoluteposition;
break;
case 'lastPage ':databox.lastPage();
datasrc.recordset.movelast();
curPage.innerText=datasrc.recordset.absoluteposition;
break;
case 'previousPage ':if(datasrc.recordset.absoluteposition> 1){
databox.previousPage();
datasrc.recordset.moveprevious();}
break;
case 'nextPage ':if(datasrc.recordset.absoluteposition <datasrc.recordset.recordcount){
databox.nextPage();
datasrc.recordset.movenext();}
break;
}
curPage.innerText=datasrc.recordset.absoluteposition;//显示当前页数
}
</script>
</head>

<body onload= "init(); ">
<!--数据源-->
<xml id= "data ">
<root>
<article>
<title> 1111111111111 </title>
<content> 11111111111111111111111111111 </content>
</article>
<article>
<title> 22222222222222222222 </title>
<content> 33333333333333333333333333 </content>
</article>
<article>
<title> 3333333333 </title>
<content> 3333333333333333 </content>
</article>
</root>
</xml>
<!-- end 数据源-->
<table border= "0 " cellpadding= "0 " cellspacing= "1 " width= "400 " align= "center " bgcolor= "green " id= "oTab " datasrc= "#data " dataPageSize= "1 ">
<tr bgcolor= "white "> <td> title </td> <td> <span datafld= "title "/> </td> </tr>
<tr bgcolor= "white "> <td> content </td> <td valign= "top "> <div datafld= "content " id= "content "> </div> </td> </tr>
</table>
<div align= "center ">
<input type= "button " name= "首页 " value= "首 页 " onClick= "page(oTab,data, 'firstPage '); ">
<input type= "button " name= "上页 " value= "上 页 " onClick= "page(oTab,data, 'previousPage '); ">
<input type= "button " name= "下页 " value= "下 页 " onClick= "page(oTab,data, 'nextPage '); ">
<input type= "button "