$ (function () {
Next page
$ ("#nextPage"). Click (function () {
Tablermove ();
var Curr = $ ("#CurrentPage"). attr ("value");
var Newcurr = number (Curr); Current page
var max = $ ("#MaxPage"). attr ("value");
var Newmax = number (max); Maximum page number
if (Newcurr >= Newmax) {
Newcurr = 1;
} else {
Newcurr = Newcurr + 1;
}
$ ("#CurrentPage"). Val (Newcurr);
if ($ ("#pagercss")!= null && $ ("#pagercss")!= "undefined") {
Getpagecss ({currpage:newcurr});
}
Gopage ();
});
Previous page
$ ("#prevPage"). Click (function () {
Tablermove ();
var Curr = $ ("#CurrentPage"). attr ("value");
var Newcurr = number (Curr);
if (Newcurr = = 1) {
var max = $ ("#MaxPage"). attr ("value");
var Newmax = number (max);
Newcurr = max;
} else {
Newcurr = newCurr-1;
}
$ ("#CurrentPage"). Val (Newcurr);
if ($ ("#pagercss")!= null && $ ("#pagercss")!= "undefined") {
Getpagecss ({currpage:newcurr});
}
Gopage ();
});
First page
$ ("#firstPage"). Click (function () {
Tablermove ();
var newcurr = 1;
$ ("#CurrentPage"). Val (Newcurr);
if ($ ("#pagercss")!= null && $ ("#pagercss")!= "undefined") {
Getpagecss ({currpage:newcurr});
}
Gopage ();
});
Last
$ ("#lastPage"). Click (function () {
Tablermove ();
var Curr = $ ("#MaxPage"). attr ("value");
var Newcurr = number (Curr);
$ ("#CurrentPage"). Val (Newcurr);
if ($ ("#pagercss")!= null && $ ("#pagercss")!= "undefined") {
Getpagecss ({currpage:newcurr});
}
Gopage ();
});
});
function Gopage () {
var formData = $ ("#pagerForm"). Serialize ();
var type = $ ("#PagerType"). Val ();
Switch (type) {
Case "1": PagerType1 (FormData); Break
Case "2": PagerType2 (FormData); Break
Case "3": PagerType3 (FormData); Break
Case "4": PagerType4 (FormData); Break
Case "5": PagerType5 (FormData); Break
Case "6": PagerType6 (FormData); Break
Case "7": PagerType7 (FormData); Break
Case "8": PagerType8 (FormData); Break
Default:pagertype1 (FormData);
}
Paging
$.ajax ({
Type: "POST",
Url:pagerurl + "? tick=" + New Date (). Getmilliseconds (),
Data:formdata,
Cache:false,
DataType: "JSON",
Success:function (data) {
Commjson.pagersync (data);
}
});
}
Generate page numbering styles
function Getpagecss (pagerdata) {
var Curr = Pagerdata.currpage | | 1; Current
var maxpage = $ ("#MaxPage"). Val ();
var max = Pagerdata.maxpage | | Number (maxpage); Maximum pages
var diff = Pagerdata.pagerdiffence | | 2; Page difference
var show = Pagerdata.showpage | | 5; Show pages
var start = (Curr-diff) > 0? (Curr + diff > Max max-show + 1:curr-diff): 1; Start Page
var end = start + Show > Max? Max + 1:start + show; End pages
if (Max < show) {//maximum pages less than display pages
for (var i = 1; i < Max; i++) {
if (Curr = = i) {
html + + ' <a style= ' color:red; "href=" javascript:void (0) "class=" pagebtn "> ' + i + ' </a> ';
} else {
html + + ' <a href= ' javascript:void (0) "class=" pagebtn "> ' + i + ' </a> ';
}
}
}
else if (Curr-diff < 0) {//current-page Difference <0
for (var i = start, I < end; i++) {
if (Curr = = i) {
html + + ' <a style= ' color:red; "href=" javascript:void (0) "class=" pagebtn "> ' + i + ' </a> ';
} else {
html + + ' <a href= ' javascript:void (0) "class=" pagebtn "> ' + i + ' </a> ';
}
}
Stitching Next Last Page
}
else if (Curr + show-1 > Max) {//Current page + Display page -1> maximum page number
Stitching Home Previous Page
for (var i = start, I < end; i++) {
if (Curr = = i) {
html + + ' <a style= ' color:red; "href=" javascript:void (0) "class=" pagebtn "> ' + i + ' </a> ';
} else {
html + + ' <a href= ' javascript:void (0) "class=" pagebtn "> ' + i + ' </a> ';
}
}
} else {
Stitching Home Previous Page
for (var i = start, I < end; i++) {
if (Curr = = i) {
html + + ' <a style= ' color:red; "href=" javascript:void (0) "class=" pagebtn "> ' + i + ' </a> ';
} else {
html + + ' <a href= ' javascript:void (0) "class=" pagebtn "> ' + i + ' </a> ';
}
}
Stitching Next Last Page
}
$ ("#pagercss"). HTML (HTML);
}
$ (". Pagebtn"). Die (). Live ("Click", Function () {
Tablermove ();
var Newcurr = number ($ (this). text ());
$ ("#CurrentPage"). Val (Newcurr);
Getpagecss ({currpage:newcurr});
Gopage ();
});