| <!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" > <head> <title>龙的传人--Xml_javascript分页</title> </head> <body onload="getxmlDoc()"> <script language="javascript" type="text/javascript"> var xmlDoc; var nodeIndex; var pageIndex; var pageSize=13; var lastPage; //最后一页 var overSize //最后一页的记录数 function getxmlDoc() { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); var currNode; xmlDoc.async=false; xmlDoc.load("myTest.xml"); if(xmlDoc.parseError.errorCode!=0) { var myErr=xmlDoc.parseError; alert("出错!" myErr.reason); } getRecordCount(); onFirst(); } function getRecordCount() { var personNode= xmlDoc.selectNodes("/Root")[0]; var recordCount=personNode.childNodes.length; var pageCount=Math.ceil(recordCount/pageSize); document.getElementById("txtPageCount").value=pageCount; document.getElementById("txtRecordCount").value=recordCount; overSize=recordCount%pageSize; if(overSize>0) { lastPage=recordCount-overSize; } else { lastPage=recordCount-pageSize; } } function getPageRecord(pageIndex,pageSize) { clearRow("myTable"); var personNode= xmlDoc.selectNodes("/Root")[0]; var currNode=personNode.childNodes[pageIndex]; for(var i=pageIndex;i<pageIndex pageSize;i ) { var arr=new Array(); var nNode= xmlDoc.selectSingleNode("Root/Person[" i "]") ; arr[0]=nNode.getAttribute("Id"); //序号 arr[1]=nNode.childNodes[0].text; //工号 arr[2]=nNode.childNodes[1].text; //姓名 arr[3]=nNode.childNodes[2].text; //性别 arr[4]=nNode.childNodes[3].text; //部门 arr[5]=nNode.childNodes[4].text; //职位 arr[6]=nNode.childNodes[5].text; //地址 // arr[0]=personNode.childNodes[i].getAttribute("Id"); //序号 // arr[1]=personNode.childNodes[i].childNodes[0].text; //工号 // arr[2]=personNode.childNodes[i].childNodes[1].text; //姓名 // arr[3]=personNode.childNodes[i].childNodes[2].text; //性别 // arr[4]=personNode.childNodes[i].childNodes[3].text; //部门 // arr[5]=personNode.childNodes[i].childNodes[4].text; //职位 // arr[6]=personNode.childNodes[i].childNodes[5].text; //地址 addRow(i 1,"myTable",arr);
|
| 共4页: 上一页 1 [2] [3] [4] 下一页 |
评论加载中…