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

Explain escape() in javascript?

487


Is there any class in javascript?

504


How to write a hello world example of javascript?

490


What is the result of below given line of code in java script? 5+4+'7'?

519


What are anonymous functions in Javascript?

540






What is strict mode in javascript?

556


What is a closure in javascript?

583


How typeof operator works?

576


What does the attribute defer/async do when added to the script tag?

536


What is Number object in JavaScript?

565


What is the meaning of callback function?

500


Explain export & import in javascript?

599


What is s+ in regex?

527


How to reload a page using JavaScript?

541


What is the use of a boolean object in javascript?

488