Error in jquery paging

Posted by Klbaiju under jQuery on 7/1/2015 | Points: 10 | Views : 650 | Status : [Member] | Replies : 2
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: Richarddaugherty on: 12/12/2019 [Member] Starter | Points: 25

Up
0
Down
The information provide in this blog is really awesome. Keep posting https://awriter.org/bestdissertation-com-review/ such type of information. Thanks for sharing the informative and perfect post.

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

Posted by: Anyageraldine on: 12/13/2019 [Member] Starter | Points: 25

Up
0
Down
I'm very happy to discover this page. [/LINK] wanted to thank you for ones time just for this wonderful read!! situs poker online resmi definitely really liked every part of it and daftar poker online terbaru also have you book marked to look at new stuff on your site. http://pokerprovip.com/

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

Login to post response