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
Can you explain the difference between == and ===?
How do you declare a variable in javascript?
what is the function of public class main ?
What is a null variable?
How to embed javascript in a web page?
How are javascript and ecma script related?
What is variables in javascript?
What does polyfill mean?
What is a closure javascript?
how to validate the date(dd/mm/yyyy)using regular expression in javascript? It should also satisfy the leap year feb 29 problem. Please help me.
What are .js files?
Why does the browser display the slow script warning?
What is the difference between push() and concat() in javascript?
How much does a javascript developer make?
What are the types of variables in javascript?