Penomoran halaman Xml_javascript
Penulis:Eve Cole
Waktu Pembaruan:2009-07-07 16:22:09
<!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 " >
<kepala>
<title>龙的传人--Xml_javascript分页</title>
</kepala>
<tubuh onload="getxmlDoc()">
<skrip bahasa="javascript" type="teks/javascript">
var xmlDok;
var nodeIndeks;
var halamanIndeks;
var ukuran halaman=13;
var halaman terakhir; //最后一页
var overSize //最后一页的记录数
fungsi getxmlDoc()
{
xmlDoc=New ActiveXObject("Microsoft.XMLDOM");
var simpul saat ini;
xmlDoc.async=salah;
xmlDoc.load("Tes saya.xml");
if(xmlDoc.parseError.errorCode!=0)
{
var myErr=xmlDoc.parseError;
alert("出错!"+myErr.alasan);
}
getRecordCount();
padaPertama();
}
fungsi getRecordCount()
{
var personNode= xmlDoc.selectNodes("/Root")[0];
var recordCount=personNode.childNodes.panjang;
var pageCount=Matematika.ceil(recordCount/pageSize);
document.getElementById("txtPageCount").value=pageCount;
document.getElementById("txtRecordCount").value=recordCount;
overSize=recordCount%pageSize;
jika(ukuran berlebih>0)
{
lastPage=recordCount-overSize;
}
kalau tidak
{
lastPage=recordCount-pageSize;
}
}
fungsi getPageRecord(pageIndex,pageSize)
{
clearRow("Tabel saya");
var personNode= xmlDoc.selectNodes("/Root")[0];
var currNode=personNode.childNodes[pageIndex];
untuk(var i=indeks halaman;i<pageIndex+ukuran halaman;i++)
{
var arr=Array baru();
var nNode= xmlDoc.selectSingleNode("Akar/Orang["+i+"]") ;
arr[0]=nNode.getAttribute("Id"); //序号
arr[1]=nNode.childNodes[0].teks; //工号
arr[2]=nNode.childNodes[1].teks; //姓名
arr[3]=nNode.childNodes[2].teks; //性别
arr[4]=nNode.childNodes[3].teks; //部门
arr[5]=nNode.childNodes[4].teks; //职位
arr[6]=nNode.childNodes[5].teks; //地址
// arr[0]=personNode.childNodes[i].getAttribute("Id"); //序号
// arr[1]=personNode.childNodes[i].childNodes[0].teks; //工号
// arr[2]=personNode.childNodes[i].childNodes[1].teks; //姓名
// arr[3]=personNode.childNodes[i].childNodes[2].teks; //性别
// arr[4]=personNode.childNodes[i].childNodes[3].teks; //部门
// arr[5]=personNode.childNodes[i].childNodes[4].teks; //职位
// arr[6]=personNode.childNodes[i].childNodes[5].teks; //地址
addRow(i+1,"Tabelku",arr);
}
}
fungsi padaPertama()
{
indeks halaman=0;
var currIndex=indeks halaman;
getPageRecord(indeks saat ini,Ukuran halaman)
pageIndex=Indeks arus ;
document.getElementById("txtCurrPage").value=(pageIndex / pageSize) + 1;
document.getElementById("txtCurrPageRecord").value=pageSize;
}
fungsi sebelumnya()
{
var currIndex=indeks halaman;
currIndex-=Ukuran halaman;
getPageRecord(indeks saat ini,Ukuran halaman)
pageIndex=Indeks arus;
document.getElementById("txtCurrPage").value=(pageIndex / pageSize) + 1;
document.getElementById("txtCurrPageRecord").value=pageSize;
}
fungsi selanjutnya()
{
var currIndex=indeks halaman;
indeks saat ini+=Ukuran halaman;
getPageRecord(indeks saat ini,Ukuran halaman)
pageIndex=Indeks arus;
document.getElementById("txtCurrPage").value=(pageIndex / pageSize) + 1;
document.getElementById("txtCurrPageRecord").value=pageSize;
}
fungsi pada Terakhir()
{
jika(ukuran berlebih>0)
{
getPageRecord(Halaman terakhir,ukuran besar)
document.getElementById("txtCurrPageRecord").value=overSize;
}
kalau tidak
{
getPageRecord(Halaman terakhir,Ukuran halaman)
document.getElementById("txtCurrPageRecord").value=pageSize;
}
pageIndex=Halaman terakhir;
document.getElementById("txtCurrPage").value=(pageIndex / pageSize) + 1;
}
fungsi keHalaman()
{
var indeks=document.getElementById("txtCurrPage").nilai
var currIndex=(indeks-1)*Ukuran halaman;
if(acara.Kode Kunci==13)
{
getPageRecord(currIndex,pageSize);
}
pageIndex=Indeks arus;
}
fungsi addRow(i,dataGridId,arr)
{
var baris=dokumen.createElement("tr");
var sel=buatCellWidthText(i);
baris.appendChild(sel);
untuk(var j=0;j<arr.panjang;j++)
{
sel=buatCellWidthText(arr[j]);
baris.appendChild(sel);
}
document.getElementById(dataGridId).firstChild.appendChild(baris);
}
fungsi membuatCellWidthText(teks)
{
var sel = dokumen.createElement("td");
var textNode = dokumen.createTextNode(teks);
sel.appendChild(textNode);
kembali sel;
}
fungsi clearRow(obj)
{
var tabel=dokumen.getElementById(obj);
var nodeTbody=tabel.anakpertama
var length=nodeTbody.childNodes.panjang;
untuk(var i=panjang-1;i>0;i--)
{
nodeTbody.removeChild(nodeTbody.childNodes[i]);
}
}
</skrip>
<form id="form1" runat="server">
<div>
<table align="center" style="border-right: #0033ff solid tipis; border-top: #0033ff solid tipis;
border-left: #0033ff tipis padat; lebar: 650 piksel; border-bottom: #0033ff solid tipis">
<tr>
<td>
共<input id="txtPageCount" name="txtPageCount" style="width: 33px; color: #0000ff; border-top-style: none; border-right-style: none; border-left-style: none; background -warna: transparan; gaya batas bawah: tidak ada;" ketik="teks" onkeydown="toPage()"/>页/
<input id="txtRecordCount" name="txtRecordCount" style="width: 46px; color: #3300ff; border-top-style: none; border-right-style: none; border-left-style: none; background- warna: transparan; gaya batas bawah: tidak ada;" ketik="teks" onkeydown="toPage()"/>条记录
<input id="btnFirst" type="button" value="首页" onclick="onFirst()"/>
<input id="btnPrev" type="button" value="上一页" onclick="onPrev()"/>
<input id="btnNext" type="button" value="下一页" onclick="onNext()"/>
<input id="btnLast" type="button" value="尾页" onclick="onLast()"/>
第<input id="txtCurrPage" name="txtCurrPage" style="width: 46px; color: #ff3333;" ketik = "teks" onkeydown = "toPage()"/>
页(当前页<input id="txtCurrPageRecord" name="txtCurrPageRecord" style="width: 22px; color: #ff3333; border-top-style: none; border-right-style: none; border-left-style: tidak ada; warna latar belakang: putih; gaya batas bawah: tidak ada;" type="text" onkeydown="toPage()"/>条记录)</td>
</tr>
<tr>
<td>
<lebar tabel = "100%" id = "Tabel Saya">
<tr style="background-color:Kuning">
<td style="lebar: 34 piksel; tinggi: 21 piksel;">
identitas</td>
<td style="lebar: 34 piksel; tinggi: 21 piksel;">
序号</td>
<td style="lebar: 42 piksel; tinggi: 21 piksel;">
工号</td>
<td style="lebar: 36 piksel; tinggi: 21 piksel;">
姓名</td>
<td style="lebar: 39 piksel; tinggi: 21 piksel;">
别</td>
<td style="lebar: 43 piksel; tinggi: 21 piksel;">
部门</td>
<td style="lebar: 50 piksel; tinggi: 21 piksel;">
dan</td>
<td style="lebar: 100 piksel; tinggi: 21 piksel;">
地址</td>
</tr>
</tabel>
</td>
</tr>
</tabel>
</div>
</bentuk>
</tubuh>
</html>
Alamat: http://home.goofar.com/lkc311/Default.htm