Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Anchor after POST Form Submission

I need to let the page loads at specific label within a page after user clicks the button Post.

Note: i'm using PHP

Form Code Sample:

<form action="po.php?id=44" method="POST">
   <input type="hidden" name="here" value="#here" />
   <input name="btn_send" type="submit" value="Post" />
</form>

The page should land somewhere in the page which has one title in between

as seen below

Code Sample:

<a name="here"></a>
<p>Total Number of Posts 55</p>

As you see, the place i land is a regular label text, not hyperlink. Therefore, i put the anchor line as an indicator just before the title.

Problem:

Page doesn't land where i put (name="here"). The page lands to the top. Is there easy way to make it land at ( name="here")?

like image 414
user311509 Avatar asked Nov 10 '11 12:11

user311509


1 Answers

Simply include the fragment in your form's action attribute, eg

<form method="post" action="po.php?id=44#here">

Also, using ID attributes as fragment locations is much nicer. Lose the empty anchor and change your paragraph to...

<p id="here">Total number of Posts 55</p>
like image 87
Phil Avatar answered Oct 01 '22 16:10

Phil