search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

Table of Contents
Xml_javascript paging
Home Backend Development XML/RSS Tutorial Xml_javascript pagination

Xml_javascript pagination

Feb 28, 2017 pm 04:52 PM

Xml_javascript paging

<!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);
    }    
}
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="首页"  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;" type="text"   onkeydown="toPage()"/>
                    页(当前页<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>

The above is the content of Xml_javascript paging. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

ArtGPT

ArtGPT

AI image generator for creative art from text prompts.

Stock Market GPT

Stock Market GPT

AI powered investment research for smarter decisions

Popular tool

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to fix the erroneous display of IE browser pages? IE browser compatibility settings How to fix the erroneous display of IE browser pages? IE browser compatibility settings Jan 09, 2026 pm 09:18 PM

The main cause of IE page confusion is a mismatch in rendering modes, which can be repaired in five steps: 1. Enable compatibility view; 2. Manually switch document mode; 3. Reset IE settings; 4. Disable third-party add-ons; 5. Check group policy restrictions.

Devin AI: Disrupting software engineering? An in-depth analysis of the future of AI software engineers Devin AI: Disrupting software engineering? An in-depth analysis of the future of AI software engineers Jan 12, 2026 pm 10:54 PM

In 2025, artificial intelligence (AI) is penetrating into various industries at an alarming rate, and the field of software engineering is no exception. Recently, an AI software engineer named DevinAI emerged, which has attracted widespread attention in the industry. DevinAI claims to be able to complete software development tasks autonomously, which has triggered concerns and discussions about whether AI will replace traditional software engineers. This article

Fishbowl test official website entrance Fishbowl graphic running score entrance Fishbowl test official website entrance Fishbowl graphic running score entrance Jan 09, 2026 pm 05:06 PM

The entrance to the Fishbowl Graphics Benchmark official website is https://fishbowl.paulkaplan.com/, which provides real-time rendering testing of three-dimensional fish tank scenes. It supports multi-dimensional visual parameter control such as fish number adjustment, bubble/reflection switch, aquatic plant density, and material reflective intensity. It also displays instantaneous FPS frame rate in real time. It has automatic increment mode and the ability to run independently on multiple tabs.

How to embed web pages in PPT for real-time display_Insert using add-ins or development tool controls How to embed web pages in PPT for real-time display_Insert using add-ins or development tool controls Jan 14, 2026 pm 07:09 PM

There are three ways to embed real-time web content in PowerPoint: 1. Use the Microsoft WebBrowser ActiveX control (Windows only); 2. Install a third-party LiveWeb add-in; 3. Add a verified official add-in like "WebViewer" from the Office App Store.

How to adjust Safari browser search settings when search results are abnormal in Safari browser How to adjust Safari browser search settings when search results are abnormal in Safari browser Jan 10, 2026 pm 12:30 PM

If Safari search results deviate from expectations, adjustments should be made in sequence: 1. Switch to the adapted default search engine; 2. Enable intelligent search suggestions and train local preferences; 3. Clear problematic website data and reset personalization; 4. Use advanced syntax such as quotation marks and minus signs for precise queries; 5. Reset search preferences and reconfigure.

Google Chrome directly opens the Google Chrome web page access version link Google Chrome directly opens the Google Chrome web page access version link Jan 14, 2026 pm 10:18 PM

The link to enter the Google Chrome web page is https://www.google.com/chrome/. This page has five core features: simple interface, stable multi-device synchronization, rich extension ecosystem, complete security protection, and strong media playback compatibility.

Quark Browser video cannot be played. Steps to troubleshoot Quark Browser playback problems. Quark Browser video cannot be played. Steps to troubleshoot Quark Browser playback problems. Jan 22, 2026 am 09:30 AM

Solutions to abnormal video playback in Quark browser include: 1. Check network connection and access permissions; 2. Clear cache and website data; 3. Enable JavaScript and H5 playback support; 4. Switch to desktop version of UA; 5. Turn off hardware acceleration and reset media services.

GitHub Copilot X: AI programming revolution, doubled efficiency! GitHub Copilot X: AI programming revolution, doubled efficiency! Jan 12, 2026 pm 10:45 PM

In the field of software development, artificial intelligence (AI) is gradually becoming a force that cannot be ignored. GitHubCopilotX, as an AI-assisted programming tool, is changing the programmer's workflow with its powerful functions and convenient use. It can not only automatically generate code based on context, but also perform code interpretation, generate unit tests and create documentation, greatly improving development

Related articles