在使用时注意先要有对应的html标签:
function pagingTwo(summary) {
if (summary != null) {
totalP = parseInt(summary.total_pages);
var cp = parseInt(summary.current_page);
var html = [];
var template = "<a href='javascript:void(0);' onclick='showPageTwo({0});'>{0}</a>";
var i = 1;
for (i = 1; i <= totalP; ++i) {
if (i == cp) {
html.push("<span>" + cp + "</span>");
} else if (i + 1 == cp || i + 2 == cp || i - 1 == cp) {
// html.push('<a href="javascript:void(0);" onclick="showPageTwo(' + i + ');">' + i + '</a>');
html.push(template.replace(/\{(\d)\}/g, function(a, b, c) {
return i;
}));
}
}
if (cp < totalP - 2) {
html.push("<span>...</span>");
html.push(template.replace(/\{(\d)\}/g, function(a, b, c) {
return totalP;
}));
} else if (cp < totalP - 1) {
html.push(template.replace(/\{(\d)\}/g, function(a, b, c) {
return totalP;
}));
}
document.getElementById("cus_page_total").innerHTML = html.join('');
}
}
function showPageTwo(page) {
console.log(page)
if (page === undefined) {
page = totalP;
}
var cu_P = page;
var actualPage = parseInt(document.getElementById('cus_page_num').value);
if (cu_P >= totalP)
document.getElementById('cus_page_num').value = parseInt(totalP);
else {
document.getElementById('cus_page_num').value = cu_P;
}
if (actualPage != cu_P) {
showCaseList();
}
}
function c_showNextP() {
var cu_P = parseInt(document.getElementById('cus_page_num').value);
if (cu_P >= totalP)
document.getElementById('cus_page_num').value = parseInt(totalP);
else {
document.getElementById('cus_page_num').value = cu_P + 1;
customerQueryby();
}
}
function c_showLastP() {
var cu_P = parseInt(document.getElementById('cus_page_num').value);
if (cu_P > 1) {
document.getElementById('cus_page_num').value = parseInt(cu_P) - 1;
customerQueryby();
}
}