Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 17th, 2009, 01:40 PM
Naughty Naughty is offline
Contributing User
Click here for more information.
 
Join Date: Jul 2009
Posts: 83 Naughty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 53 m 8 sec
Reputation Power: 1
Question Waan try Javascript too

Hey,

As I'm working with pagination using php. I just wanted to try Javascript too. So pagination.js script

Code:
//function call for the table name and number of items perpage
function Pager(tableName, itemsPerPage) {
this.tableName = tableName;
this.itemsPerPage = itemsPerPage;
this.currentpage = 1;
this.pages = 0;
this.initied = false;

//calls the function 
this.showRecords = function(from, to) {

var rows = document.getElementById(tableName).rows;
for(var i= 1; i< rows.length; i++) {
if(i < from || i > to)
rows[i].style.display = 'none';
else
rows[i].style.display = '';
}
}



this.showPage = function(pageNumber){
if(!this.inited){
alert("not inited");
return;
}

//to show the previous page
var oldPageAnchor = document.getElementById('pg'+this.currentpage);
oldPageAnchor.className = 'pg-normal';

//current page
this.currentpage = pageNumber;
var newPageAnchor = document.getElementById('pg'+this.currentpage);
newPageAnchor.className = 'pg-selected';

//definitions for from and to variables used in the above function
var from = (pageNumber - 1) * itemsPerPage + 1;
var to = from + itemPerPage - 1;
this.showRecords(from, to);
}



//previous function
this.prev = function(){
if(this.currentpage > 1){
this.showPage(this.currentpage - 1);
}
}


//next function
this.next = function(){
if(this.currentpage < this.pages){
this.showPage(this.currentpage + 1);
}
}


this.init = function(){
var rows = document.getElementById(tableName).rows;
var records = (rows.length - 1);
this.pages = Math.ceil(records / itemsPerPage);
this.inited = true;
}


this.showPageNav = function(pagerName, positionId){
if(!this.inited){
alert("not inited");
return;
}

var element = document.getElementById(positionId);

var pagerHtml = '<span onclick=" +pagerName + '.prev();" class="pg-normal"> &#171 Prev</span> |';
for(var page = 1; page <= this.pages; page++)
pagetHtml +=<span id="pg"+ page + '"class="pg-normal" onclick="' + pagerName + '.showPage(' + page +');">' + page + '</span> |';

pagetHtml += '<span onclick="'+pagerName+'.next();" class="pg-normal"> Next »</span>';
element.innerHTML = pagerHtml;
}
}


so I use the below code to be called in my html page

Code:
<html>
<head>
<style type="text/css">
.pg-normal{
color: black;
font-weight: normal;
text-decoration: none;
cursor: pointer;
}

.pg-selected{
color: black;
font-weight: bold;
text-decoration: underline;
curosr: pointer;
}
</style></head></html>



Code:

<div id="pageNavPosition"></div>
<script type="text/javascript">
var pager = new Pager("csv", 8);
pager.init();
pager.showPageNav('pager', 'pageNavPosition');
pager.showPage(1);
</script>


The problem is my html page is kinda of complicated, where it has from and to date text box, with calender.

few more text boxes. and finally the submit image.

I tried to run the script but it doesn't seem to work.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Waan try Javascript too


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek