Error in jquery paging

Posted by Klbaiju under jQuery on 7/1/2015 | Points: 10 | Views : 335 | Status : [Member] | Replies : 1
Hi,
in my application iam using paging by jquery.
eg i have 10 records and want to display 4 records at a time.
paging has forward and backward buttons.
following is the code.
$(document).ready(function () {
var rows = 10;
var no_rec_per_page = 3;
var modtest = rows % no_rec_per_page;
var no_pages = Math.ceil(rows / no_rec_per_page);
$('#pages').empty();
$('#pages').show();
var cnt = 10;
var $rcount = "There are " + cnt + " Records";
var disp = $('<div id="dp"></div>');
$(disp).html($rcount).css('color', 'Green');
var $pagenumbers = $('<div id="pages"></div>');
var html = '<a id="prev" title="previous" href=\"#\"> <<</a>';
var k = Math.ceil(cnt / 4);
console.log(k);
for (i = 0; i <= k; i++) {
html = html + '<a href="#" id="' + (i + 1) + '" class="page">' + (i + 1) + '</a>';
}

html = html + '<a title="Next" id="next" href=\"#\"> >></a>';
$(html).appendTo($pagenumbers);
$pagenumbers.insertAfter('#st');
$(disp).insertAfter($pagenumbers);
i = 0;
$('#next').click(function () {

$('#pages').empty();
k = k + 4;
i = i + 4;
var disp = $('<div id="dp"></div>');
var $pagenumbers = $('<div id="pages"></div>');
var html = '<a id="prev" title="previous" href=\"#\"> <<</a>';
for (i; i <= k; i++) {
html = html + '<a href="#" id="' + (i + 1) + '" class="page">' + (i + 1) + '</a>';

}
html = html + '<a title="Next" id="next" href=\"#\"> >></a>';
$(html).appendTo($pagenumbers);
$pagenumbers.insertAfter('#st');
$(disp).insertAfter($pagenumbers);
});
$('#prev').click(function () {
console.log(i);
$('#pages').empty();
var disp = $('<div id="dp"></div>');
var $pagenumbers = $('<div id="pages"></div>');
var html = '<a id="prev" title="previous" href=\"#\"> <<</a>';
i = i - 3;
k = k - 3;
for (i; i < k; i++) {
html = html + '<a href="#" id="' + (i + 1) + '" class="page">' + (i + 1) + '</a>';
}

html = html + '<a title="Next" id="next" href=\"#\"> >></a>';
$(html).appendTo($pagenumbers);
$pagenumbers.insertAfter('body');
$(disp).insertAfter($pagenumbers);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="st"></div>
</form>
</body>
</html>


here only forward button is working.but only for one click.
backward button doesn't display any record .
plz find this url
http://jsfiddle.net/klbaiju/mupbnng2/2/

how to solve this

Regards
Baiju




Responses

Posted by: Margaretmbrooks on: 7/3/2015 [Member] Starter | Points: 25

Up
0
Down
In this program code I couldn't see any mistakes. Please submit your problem as an assignment topic to any custom essay writing service [http://buyessays.us] . They may provide the answer.

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response