The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> JavaScript Development
|
Navigation through records
Discuss Navigation through records in the JavaScript Development forum on Dev Shed. Navigation through records JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 2nd, 2012, 11:55 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 3
Time spent in forums: 1 h 32 m 33 sec
Reputation Power: 0
|
|
|
Navigation through records
hi, I am generating records through php/sql, as u can see the code displays 5 records, what Im trying to do is program so that when the next button is pressed the next 5 records will show?? any help much appreciated thank you,
the code -
Code:
function show(qstring,qtype){
$("#vsdiv").show();
var myurl="scripts/searchpage.php";
$.ajax({
url: myurl, dataType:'json',data:{querystring:qstring,querytype:qtype},
success: function(member){
$("#results").append('<tr class="me">'+
'<th>#REC</th><th>name</th><th>surname</th>');
var j=0;var totrecs=1;
for(var i=0;i<5;i++){
$("#results").append('<tr class="rows'+j+'">'+
'<td class="ids" id="z'+i+'">'+totrecs+'</td>'+
'<td>'+name[i].bdate+'</td>'+
'<td class="users" id="username'+i+'">'+member[i].username+'</td>'+
'<td id="contact'+i+'">'+member[i].fname+' '+member[i].lname+'</td>'+
'<td><input type="checkbox" name="whome" id="showMe'+i+'"'+
'class="boxes" onclick="getMe('+i+')" /></td></tr>');
totrecs++;
j++;
}
}
});
}
and for the html button -
Code:
<input type="button" id="next5" title="Next 5 Records" disabled="disabled" value="Next 5>>" />
|

November 2nd, 2012, 12:03 PM
|
|
|
|
Welcome to DevShed, davidp.
A variable with an increment of 5 per click should do the trick. Where is the event function for the button?
Leaving work in 5 minutes, so someone else may need to reply.
|

November 2nd, 2012, 12:09 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 3
Time spent in forums: 1 h 32 m 33 sec
Reputation Power: 0
|
|
|
Thanks you, I dont yet have the event function for the button, any help with the code for the next button?? dont know how to start it
|

November 2nd, 2012, 01:23 PM
|
|
|
|
you could easily do this in php using pagination and then using ajax so it doesn't reload the entire page every time the next or back button is clicked
|

November 2nd, 2012, 02:28 PM
|
|
|
The script is already using jQuery's AJAX functions. So, you already have your JSON object you are sending to your server-side script. You just need to add a pagination number to it. Here is a pseudo-example to give you the concept.
Javascript Code:
Original
- Javascript Code |
|
|
|
var recordCount = 0; function show(args) { // existing code. dataType:'json',data:{querystring:qstring,querytype:qtype,rcount:recordCount} // existing code. recordCount += 5; }
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|