Javascript paging Program

Source: Internet
Author: User
When creating a project, you must use ajax without refreshing pages. You can give up the idea because you are not very familiar with the pagerhealkaline class. Think of the pages previously written using SQL stored procedures, so I want to use javascript and Jquery to write a paging program. Below I will only write the paging function, jquery's ajax request is omitted. 1 function Pagers (page)
2 {
3 var div = document. createElement ("div ");
4 div. id = "bar ";
5 document. getElementById ("pager"). appendChild (div );
6 var j = (page-3 <1 )? 1: page-3;
7 var k = (page + 3> maxpage )? Maxpage: page + 3;
8 if (j> 1)
9 {
10 var a = document. createElement ("");
11 a. href = "#";
12 a. innerHTML = "";
13 document. getElementById ("bar"). appendChild ();
14}
15 for (var I = j; I <k + 1; I ++)
16 {
17 if (I! = K)
18 {
19 var a = document. createElement ("");
20 var s = I;
21 a. href = "javascript: reloadpager (); Pagers (" + I + ");";
22 a. innerHTML = I;
23 document. getElementById ("bar"). appendChild ();
24 continue;
25}
26 if (maxpage> k)
27 {
28 var a = document. createElement ("");
29 a. href = "#";
30 a. innerHTML = "";
31 document. getElementById ("bar"). appendChild ();
32 var a = document. createElement ("");
33 a. href = "#";
34 a. onclick = "reloadpager (); Pagers (" + maxpage + ");";
35 a. innerHTML = maxpage;
36 document. getElementById ("bar"). appendChild ();
37}
38}
39
40}
41 function reloadpager ()
42 {
43 var pp = document. getElementById ("bar ");
44 document. getElementById ("pager"). removeChild (pp );
45}

It may be helpful to everyone!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.