Xml_javascript分頁_Xml教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:教你一種 .NET中書寫XML的簡單方法XML是一項(xiàng)熱門的技術(shù)。它之所以能夠引起人們的興趣,一個(gè)主要的原因在于它十分的簡單,人們可以很容易地理解和使用它。每一個(gè)程序員都能輕易地看懂一個(gè)XML文件,理解它包含的內(nèi)容。 .NET中包
Xml_javascript分頁實(shí)例:
<!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 //最后一頁的記錄數(shù) 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("出錯(cuò)!" 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); } } function onFirst() { pageIndex=0; var currIndex=pageIndex; getPageRecord(currIndex,pageSize) pageIndex=currIndex ; document.getElementById("txtCurrPage").value=(pageIndex / pageSize) 1; document.getElementById("txtCurrPageRecord").value=pageSize; } function onPrev() { var currIndex=pageIndex; currIndex-=pageSize; getPageRecord(currIndex,pageSize) pageIndex=currIndex; document.getElementById("txtCurrPage").value=(pageIndex / pageSize) 1; document.getElementById("txtCurrPageRecord").value=pageSize; } function onNext() { var currIndex=pageIndex; currIndex =pageSize; getPageRecord(currIndex,pageSize) pageIndex=currIndex; document.getElementById("txtCurrPage").value=(pageIndex / pageSize) 1; document.getElementById("txtCurrPageRecord").value=pageSize; } function onLast() { if(overSize>0) { getPageRecord(lastPage,overSize) document.getElementById("txtCurrPageRecord").value=overSize; } else { getPageRecord(lastPage,pageSize) document.getElementById("txtCurrPageRecord").value=pageSize; } pageIndex=lastPage; document.getElementById("txtCurrPage").value=(pageIndex / pageSize) 1; } function toPage() { var index=document.getElementById("txtCurrPage").value var currIndex=(index-1)*pageSize; if(event.keyCode==13) { getPageRecord(currIndex,pageSize); } pageIndex=currIndex; } function addRow(i,dataGridId,arr) { var row=document.createElement("tr"); var cell=createCellWidthText(i); row.appendChild(cell); for(var j=0;j<arr.length;j ) { cell=createCellWidthText(arr[j]); row.appendChild(cell); } document.getElementById(dataGridId).firstChild.appendChild(row); } function createCellWidthText(text) { var cell = document.createElement("td"); var textNode = document.createTextNode(text); cell.appendChild(textNode); return cell; } function clearRow(obj) { var table=document.getElementById(obj); var nodeTbody=table.firstChild var length=nodeTbody.childNodes.length; for(var i=length-1;i>0;i--) { nodeTbody.removeChild(nodeTbody.childNodes[i]); } } </script> <form id="form1" runat="server"> <div> <table align="center" style="border-right: #0033ff thin solid; border-top: #0033ff thin solid; border-left: #0033ff thin solid; width: 650px; border-bottom: #0033ff thin solid"> <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-color: transparent; border-bottom-style: none;" type="text" 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-color: transparent; border-bottom-style: none;" type="text" onkeydown="toPage()"/>條記錄 <input id="btnFirst" type="button" value="http://www.hl5o.cn/首頁" onclick="onFirst()"/> <input id="btnPrev" type="button" value="http://www.hl5o.cn/上一頁" onclick="onPrev()"/> <input id="btnNext" type="button" value="http://www.hl5o.cn/下一頁" onclick="onNext()"/> <input id="btnLast" type="button" value="http://www.hl5o.cn/尾頁" onclick="onLast()"/> 第<input id="txtCurrPage" name="txtCurrPage" style="width: 46px; color: #ff3333;" type="text" onkeydown="toPage()"/> 頁(當(dāng)前頁<input id="txtCurrPageRecord" name="txtCurrPageRecord" style="width: 22px; color: #ff3333; border-top-style: none; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none;" type="text" onkeydown="toPage()"/>條記錄)</td> </tr> <tr> <td> <table width="100%" id="myTable"> <tr style="background-color:Yellow"> <td style="width: 34px; height: 21px;"> Id</td> <td style="width: 34px; height: 21px;"> 序號</td> <td style="width: 42px; height: 21px;"> 工號</td> <td style="width: 36px; height: 21px;"> 姓名</td> <td style="width: 39px; height: 21px;"> 性別</td> <td style="width: 43px; height: 21px;"> 部門</td> <td style="width: 50px; height: 21px;"> 職位</td> <td style="width: 100px; height: 21px;"> 地址</td> </tr> </table> </td> </tr> </table> </div> </form> </body> </html> |
分享:用帶批注的 XDR 架構(gòu)創(chuàng)建 XML 視圖可以使用 XDR(簡化 XML-Data)架構(gòu)創(chuàng)建關(guān)系數(shù)據(jù)的 XML 視圖。然后可以使用 XPath 查詢來查詢這些視圖。這類似于使用 CREATE VIEW 語句創(chuàng)建視圖并指定對視圖的 SQL 查詢。 XML 架構(gòu)描述 XML
相關(guān)Xml教程:
- xml創(chuàng)建節(jié)點(diǎn)(根節(jié)點(diǎn)、子節(jié)點(diǎn))
- WML開發(fā)教程之 WAP網(wǎng)站服務(wù)器配置方法
- WMLScript的語法基礎(chǔ)
- 收集的WML Script標(biāo)準(zhǔn)函數(shù)庫
- WML教程之文本框控件Input
- 無線標(biāo)記語言(WML)基礎(chǔ)之WMLScript 基礎(chǔ)
- xml文件的結(jié)構(gòu)解讀
- 關(guān)于XSL - XSL教程
- 選擇模式 - XSL教程 - 2
- XPath入門 - XSL教程 - 3
- 匹配模式 - XSL教程 - 4
- 測試模式 - XSL教程 - 5
- 相關(guān)鏈接:
- 教程說明:
Xml教程-Xml_javascript分頁
。