Write sample code for pagination using java script.

Answer Posted / sonylal

To use my javascript you need to:

1. include the javascript using <script src="pager.js">
in your page header;
2. include a small css to skin the page navigation-bar
(i.e. for emphasizing the selected page using bold and
underline style);
3. define an ID on the table you want to scroll. i.e.
<table id="results"> ;
4. place an empty <div/> in the place you want to display
the navigation bar. i.e. <div id="pageNavPosition"> ;
5. include an initialization script at the bottom of your
page like this:

<script type="text/javascript"><!--
var pager = new Pager('results', 3);
pager.init();
pager.showPageNav('pager', 'pageNavPosition');
pager.showPage(1);
//--></script>

Where 'results' is the id of the table (see step #3), 3 is
the number of records per page, 'pager' is the name of the
variable (in red... that's ugly I agree...), and
pageNavPosition is the ID of the DIV inside of which the
pagination bar will be placed. The showPage(1) indicates
that, when loading the page, the 1st one should be displayed.


Regards
www.jobpuja.com

Is This Answer Correct ?    47 Yes 28 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is null in js?

655


How to modify the url of the page without reloading the page?

652


What is the data type of variables of in javascript?

686


Explain mul function in javascript?

699


What is javascript namespacing?

706


What are all the types of Pop up boxes available in JavaScript?

786


What are javascript closures?when would you use them?

703


How to add/remove properties to object dynamically in javascript?

681


What is a noscript tag?

621


What is difference between callback and promise?

638


Why javascript is called lightweight language?

664


What is a class in javascript?

670


What is difference between local variable and global?

658


Why is javascript so popular?

643


What are associative arrays in javascript?

736