I am attempting to show two records at a time from a database query. I have previous and next buttons that work. However, I am wanting to include a "jump to" pull down menu as part of the functionality.
To get this to work, I am needing to pass a variable stating what page I am on through a JavaScript onChange function. If I print the variable to the page outside of the onChange function, it shows the correct page number. If I use the variable inside of the onChange function it is not coming out correctly. It is holding the value of the previous page instead of the current page.
Am I missing something or is there a different way to include a variable in a JavaScript function. Your insight is appreciated.
Code:
<?
$marker = 1;
if ($offset == 0)
{$marker = 1;}
else
{$marker = ($offset/2) + 1;}
?>
<form>
<?
print($marker);
?>
<br><br>
<select name="PageJump" onChange="top.location.href='sample.phtml?page=<? print($marker); ?>&offset='+ this.options[selectedIndex].value">
<?
for ($i=1;$i<=$pages;$i++){
$newoffset=$limit*($i-1);
print("<option value=" . $newoffset . " >page " . $i . "</option>");
}
?>
</select>
</form>
The first print($marker) is correct. The print($marker) located inside the JavaScript is not.
Thank you for any help.