Implement pagination with JavaScript + XML

xiaoxiao2021-03-06  59

Based on web-based technology, the paging is an old can no longer be old, but everyone is the problem, with the income application of XML technology, it is also a possibility, of course, there are many tutorials. When I have seen the stunned, I will write one, share it with you, and correct.

There are two files TMH.htm & tt.xml

The source code is as follows:

TMH.htm

_________________________________________________

new document </ title></p> <p><Meta name = "generator" Content = "Editplus"></p> <p><Meta name = "author" content = ">></p> <p><Meta name = "keywords" content = ">></p> <p><Meta name = "description" content = ">></p> <p><link rel = "stylesheet" href = "../ Website.css" Type = "text / css"></p> <p></ HEAD></p> <p><Body></p> <p><script language = "javascript"></p> <p>// *************** Variables related definitions *************</p> <p>// * Author: 海 仔 *</p> <p>// * email: Rautinee@21cn.com *</p> <p>// * This program is free to disseminate, but please keep this information *</p> <p>// ***************************************</p> <p>VAR PAGENUM = 4; // Show a few messages per page</p> <p>VAR Page = 0;</p> <p>Var continpage;</p> <p>Var bodytext = "";</p> <p>VAR XMLDoc = New ActiveXObject ("Microsoft.xmLDom");</p> <p>Var mode = "member";</p> <p>Var Toolbar;</p> <p>XMLDoc.async = "false"</p> <p>XMLDoc.Load ("tt.xml")</p> <p>// ************** This place is you changed according to the actual field name.</p> <p>Header = "<Table Border = 1> <TD> <TD> Icon </ TD> <TD> IP Address </ TD> <TD> Email </ TD> <TD> </ TD> <TD> Date </ TD> <TD> </ TD> <TD> </ TD> </ TR></p> <p>// Retrieve the number of records</p> <p>Maxnum = xmldoc.getlementsBytagname (Mode) .length</p> <p>// The number of columns per record</p> <p>Column = xmldoc.getElementsBytagname (mode) .Item (0) .childNodes</p> <p>// The number of columns per record</p> <p>Colnum = column.length</p> <p>// Page number</p> <p>PagesNumber = Math.ceil (MAXNUM / PAGENUM) -1;</p> <p>Pagesnumber2 = Math.ceil (MaxNum / Pagenum);</p> <p>// Previous page</p> <p>Function uppage (Page)</p> <p>{</p> <p>Thepage = "Previous page";</p> <p>IF (Page 1> 1) thepage = "<a href='#' οnclick='javascript:Return Uppagego() 'Previous page </a>";</p> <p>Return thepage;</p> <p>}</p> <p>Function NextPage (Page)</p> <p>{</p> <p>Thepage = "Take the next page";</p> <p>IF (PageSnumber) thepage = "<a href = '#' οnclick = 'javascript: return nextpagego ()> Next page </a>";</p> <p>Return thepage;</p> <p>}</p> <p>Function uppagego () {</p> <p>IF (Page> 0) Page -;</p> <p>GetContent ();</p> <p>Bodytext = ""</p> <p>}</p> <p>// Current number of pages</p> <p>Function CurrentPage ()</p> <p>{</p> <p>VAR CP;</p> <p>CP = "Currently No. (Page 1) " Page ";</p> <p>Return CP;</p> <p>}</p> <p>// Total number of pages</p> <p>Function allpage ()</p> <p>{</p> <p>VAR AP;</p> <p>AP = 'total' (Pagesnumber 1) 'page';</p> <p>Return AP</p> <p>}</p> <p>Function nextpagego ()</p> <p>{</p> <p>IF (Page <PagesNumber) Page ;</p> <p>GetContent ();</p> <p>Bodytext = ""</p> <p>}</p> <p>// Display Package Status Bar</p> <p>Function Pagebar (Page)</p> <p>{</p> <p>VAR PB;</p> <p>PB = UPPAGE (PAGE) " NEXTPAGE (PAGE) " " Allpage () SelectPage ();</p> <p>Return PB;</p> <p>}</p> <p>Function ChangePage (TPAGE)</p> <p>{</p> <p>Page = TPAGE</p> <p>IF (Page> = 0) Page -;</p> <p>IF (Page <PagesNumber) Page ;</p> <p>GetContent ();</p> <p>Bodytext = ""</p> <p>}</p> <p>Function selectpage ()</p> <p>{</p> <p>VAR SP;</p> <p>Sp = "<select name = 'Hehe' onchange = 'JavaScript: ChangePage (this.Options [this.selected" ";</p> <p>// sp = "<select name = 'Hehe' onchange = 'alert (this.Options [this.selectedindex] .value)'></p> <p>SP = SP "<option value = ''> </ option>"; for (t = 0; t <= PageSnumber; t )</p> <p>{</p> <p>SP = SP "<option value = '" t "" " (t 1) " </ option> ";</p> <p>}</p> <p>SP = SP "</ SELECT>"</p> <p>Return SP;</p> <p>}</p> <p>Function getContent ()</p> <p>{</p> <p>IF (! Page) Page = 0;</p> <p>N = Page * PAGENUM;</p> <p>Endnum = (page 1) * Pagenum;</p> <p>IF (Endnum> Maxnum) endnum = maxnum;</p> <p>BodyText = Header BodyText;</p> <p>For (; n <Endnum; n )</p> <p>{</p> <p>Bodytext = BodyText "<tr>";</p> <p>For (m = 0; m <= colnum-1; m )</p> <p>{</p> <p>MNAME = column.Item (m) .tagname;</p> <p>Bodytext = bodytext ("<TD>" XMLDoc.getElementsBytagname (MNAME) .Item (n) .text "</ td>");</p> <p>}</p> <p>Bodytext = bodytext "</ tr>"</p> <p>mm = ""</p> <p>}</p> <p>Showhtml.innerhtml = bodytext "</ table>" Pagebar (Page);</p> <p>Bodytext = ""</p> <p>}</p> <p></ script></p> <p><div id = "showhtml"> </ div></p> <p><script></p> <p>IF (MAXNUM == 0)</p> <p>{</p> <p>Document.write ("No Suitable Talent Information")</p> <p>}</p> <p>Else</p> <p>{</p> <p>GetContent ()</p> <p>}</p> <p></ script></p> <p></ Body></p> <p></ Html></p> <p>// below is a tt.xml code</p> <p><? XML Version = "1.0" encoding = "GB2312"?></p> <p><Rautinee></p> <p><member id = '1'></p> <p><name> 海 仔 </ name></p> <p><loginname> Rautinee </ loginname></p> <p><email> Rautinee@btamail.net.cn </ email> </ member></p> <p><member id = '2'></p> <p><Name> Just Qiang </ Name></p> <p><loginname> Hehe </ loginname></p> <p><email> Rautinee@chinaManagers.com </ email> </ member></p> <p><member id = '3'></p> <p><Name> Jin Huang </ Name></p> <p><loginname> Nature_IT </ loginname> <email> Rautinee_sea@hotmail.com </ email> </ member></p> <p><Member ID = '4'></p> <p>简强 强强 </ name></p> <p><loginname> Tank </ loginname></p> <p><email> Tank@163.com </ email> </ member></p> <p><member id = '7'></p> <p><Name> Joint venture </ Name></p> <p><loginname> Kaka </ loginname></p> <p><email> kaka@eyou.com </ email> </ member></p> <p><member id = '6'></p> <p><Name> Add personal </ name></p> <p><loginname> apple </ loginname></p> <p><email> apple@163.com </ email> </ member></p> <p><Member ID = '8'></p> <p><name> null </ name></p> <p><loginname> sunny </ loginname></p> <p><email> Rautinee@eyou.com </ email> </ member></p> <p><member id = '10 '></p> <p><Name> Baby </ Name></p> <p><loginname> Index </ loginname></p> <p><email> Rautinee@21cn.com </ email> </ member></p> <p><member id = '12 '></p> <p><name> null </ name></p> <p><loginname> Login </ loginname></p> <p><email> Webmaster@chinaManagers.com </ email> </ member></p> <p><member id = '13 '></p> <p><name> jiang </ name></p> <p><loginname> 123 </ loginname></p> <p><email> japing@chianManagers.com </ email> </ member></p> <p><Member ID = '14 '></p> <p><name> null </ name></p> <p><loginname> World </ loginname></p> <p><email> Rautinee@21cn.com </ email> </ member></p> <p><member id = '15 '></p> <p><name> null </ name></p> <p><loginname> Swallow </ loginname></p> <p><email> swallow@chinaManagers.com </ email> </ member></p> <p><member id = '16 '></p> <p><Name> Weiger </ name></p> <p><loginname> Hotmail </ loginname> <email> Rautinee_sea@hotmail.com </ email> </ member></p> <p><member id = '17 '></p> <p><name> null </ name></p> <p><loginname> WRONG </ loginname></p> <p><email> Wrong@chinaManagers.com </ email> </ member></p> <p><member id = '18 '></p> <p><name> null </ name></p> <p><loginname> Leah </ loginname></p> <p><email> Leah@chinaManagers.com </ email> </ member></p> <p><member id = '19 '></p> <p><name> null </ name></p> <p><loginname> TTth </ loginname></p> <p><email> Rautinee@21cn.com </ email> </ member></p> <p></ RAUTINEE></p> <p>Currently only support> IE5.0</p> <p>If you have any good way and improve, let me let me not know, or visit the website.</p> <p>Http://www.tryitsoft.com Thank you.</p> <p>OK, Just Enjoy It, And Good Luck</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-90296.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="90296" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.038</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'LRyH2MeqggLHeVkkHvLmpeUGXpbjDdjN4ZBiDAo917F4DYbVtqTRxFrmvPZ1yxqlpR7XFTRGYVitgrtMaJnZVQ_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>