Penomoran halaman Xml_javascript
Penulis:Eve Cole
Waktu Pembaruan:2009-07-07 16:22:09
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
http://www.w3.org/1999/xhtml " >
龙的传人--Xml_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 {
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 {
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]);
}
}