Jump to content

Getting the first 50 results with js


kansasakki

Recommended Posts

I am having trouble getting the line

 

<a href="javascript:void(0)" onClick="getPosition(1)">First</a> to work correctly and pull the first 50.  I think I have everything else working.

 

work in process can be seen at http://www.1dayreturn.com/activity.php

 

I have been spinning my wheels for about 5 hours.

 

The get Get Older Positions: value is set to show which else statement is currently being view.  Any help would be greatly appreciated.

 


function getPosition(pageNumber){
	document.getElementById('lastfifty').innerHTML = '<div style="text-align:center;"><img src="loadingbg.gif" /></div>';
	$.ajax({  
        	type: "POST", url: 'getpositions.php', data: "filter1="+pageNumber+"&filter2=<?php $pcount = $previouspositions['pcount']; echo $pcount;?>",
            complete: function(data){  
			//print results as appended   
			//targetDiv.append(data.responseText);  
			//print result in targetDiv  
			document.getElementById('lastfifty').innerHTML = (data.responseText);
			var last = <?php $pcountholder = number_format($pcount/50,0);echo $pcountholder;?>;
			var first = last - (last -1);
			if(pageNumber != 'last'){
				var last= <?php $pcountholder = number_format($pcount/50,0);echo $pcountholder;?>;
				var next= pageNumber+1;
				var prev= pageNumber-1;
				if(pageNumber >= last){
					pageNumber = <?php $pcountholder = number_format($pcount/50,0);echo $pcountholder;?>;
					prev = pageNumber-1;
					next = pageNumber +1;
				}
				if(prev < 0){prev = 0;pageNumber = 1;next = 2;}
				if (pageNumber != 1){
					if(pageNumber == last){
					last == <?php $pcountholder = number_format($pcount/50,0);echo $pcountholder;?>;
					pageNumber == last;
					next = pageNumber +1;
					prev = pageNumber -1;
					document.getElementById('prevnav').innerHTML = '<h2>Last 502 Positions</h2> <div style="float:right">Get Older Positions: Positions: <a href="javascript:void(0)" onClick="getPosition(1)">First</a> | Prev | '+pageNumber+' | <a href="javascript:void(0)" onClick="getPosition('+next+')">Next</a> | <a href="javascript:void(0)" onClick="getPosition(\'last\')">Last</a></div>';
					}						
					else{
						if(next == last){
							next = "\'last\'";
						}
						document.getElementById('prevnav').innerHTML = '<h2>Last 503 Positions</h2> <div style="float:right">Get Older Positions: <a href="javascript:void(0)" onClick="getPosition(1)">First</a> | <a href="javascript:void(0)" onClick="getPosition('+prev+')">Prev</a> | '+pageNumber+' | <a href="javascript:void(0)" onClick="getPosition('+next+')">Next</a> | <a href="javascript:void(0)" onClick="getPosition(\'last\')">Last</a></div>';
					}
				}else{
					pageNumber = 1;
					next = pageNumber +1;
					document.getElementById('prevnav').innerHTML = '<h2>Last 504 Positions</h2> <div style="float:right">Get Older Positions: First | Prev | '+pageNumber+' | <a href="javascript:void(0)" onClick="getPosition('+next+')">Next</a> | <a href="javascript:void(0)" onClick="getPosition(\'last\')">Last</a></div>';
				}
			}else{
				var last= <?php $pcountholder = number_format($pcount/50,0);echo $pcountholder;?>;
				pageNumber = last;
				var prev = last-1;  
				document.getElementById('prevnav').innerHTML = '<h2>Last 505 Positions</h2> <div style="float:right">Get Older Positions: <a href="javascript:void(0)" onClick="getPosition('+first+')">First</a> | <a href="javascript:void(0)" onClick="getPosition('+prev+')">Prev</a> | '+pageNumber+' | Next | Last</div>';
			}
         	}  
         });
}

 

Thanks

 

Kansas

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.