I have the following code that is applied to a forward and next button. I also have the submit button that starts the process. It is desired that after you hit submit button (#lookup) it shows the forward and next to paginate through the results. The problem is that after the initial submit/#lookup and you hit forward and submit another search it shows the results from the second set/where you were on the first search after hitting next (IE starts at results 51-100 instead of back at 1). I need to modify the following
function changestart(direction)
{
var rowsElement = $("#maxrows");
var rowsValue = parseInt(rowsElement.val());
var startElement = $("#startID");
var value = parseInt(startElement.val());
startElement.val(direction == "forward" ? value + rowsValue : direction == "back" ? value -
rowsValue : 1);
}
$("#previous").click(function(){changestart('back');});
$("#next").click(function(){changestart('forward');});
// not working
$("#lookup").click(function(){changestart('???');});
EDIT – the button currently has this inline JS
<input id="lookup" type="submit" name="lookup" value="Search" onclick="changestart('1')" />
How do I apply a click function to the submit button “#lookup” that starts the search back at 1?
thx
There are probably a lot of ways, but why not treat direction as a optional argument, which when not set indicates a reset condition.