i have a small report generated at the bottom of a page.
it has pagination numbers. all these ajax generated.
now the pagination numbers have the following code.
echo "<a [B]href=[/B]\\"[B]#[/B]\\" id='$i' class='pagenum' onclick='ajaxpost_rep_gen($i);change($i)'/>" . $i . "</a>" . " ";
notice that for hreaf i have put #.
now my problem is, when click a pagination number, the page is scrolled to the top of the page.
so each time when click a pagination number at the bottom, user have to scroll down to see the report's next page.
screen shot of the report :
I don't have a lot of experience with inline event handlers, but I believe this is an easy fix. Two main solutions:
- Add "return false" to the end of the "onclick" code.
Do either of those help?
Go with the second option, which ensures that when clicking on the link, the browsers default behaviour doesn't not occur.
all i can say is ur a genius paul !!!
echo "<a href=\\"#\\" id='$i' class='pagenum' onclick='ajaxpost_rep_gen($i);change($i);return false;'/>" . $i . "</a>" . " ";
both method worked charm. i stick with the above method as per ur advise.
It's better to use techniques that make it easier to understand what is going on. Returning false from the onclick event serves that purpose nicely.
The other reason to use the return false from the onclick event is that it allows you to cleanly separate the scripting from the content.
This topic is now closed. New replies are no longer allowed.