# Redirect the user to the exact same spot within a page, where (s)he previously left off from

**URL:** <https://discourse.cakephp.org/t/redirect-the-user-to-the-exact-same-spot-within-a-page-where-s-he-previously-left-off-from/7521>\
**Category:** Need Help\
**Created:** [March 22, 2020, 9:23pm UTC](https://discourse.cakephp.org/t/redirect-the-user-to-the-exact-same-spot-within-a-page-where-s-he-previously-left-off-from/7521 "2020-03-22T21:23:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![IamDheerajS](https://avatars.discourse-cdn.com/v4/letter/i/f07891/32.png) [@IamDheerajS](https://discourse.cakephp.org/u/IamDheerajS)\
**Post date:** [March 22, 2020, 9:23pm UTC](https://discourse.cakephp.org/t/redirect-the-user-to-the-exact-same-spot-within-a-page-where-s-he-previously-left-off-from/7521/1 "2020-03-22T21:23:36Z")

</div>

Hello, everyone!

I’m a beginner to CakePHP and I’m very excited to to work with it too, I started reading the documentation a few days ago!

And decided to work on an application, so in it, I have a list of records which I edit repeatedly.

**Problem :** Whenever I work on a particular record and save my work, the web page returns me to the _top_ of the page.  
**Expected Result :** After saving my work, I need to return at the _exact same spot_ where I made the edited previously.

Is there any Cake-ish way to achieve this? I have no clue how to get this done, I searched on google but no luck yet.

I would really appreciate if anyone can help me with this, thanks a lot!

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [March 22, 2020, 9:47pm UTC](https://discourse.cakephp.org/t/redirect-the-user-to-the-exact-same-spot-within-a-page-where-s-he-previously-left-off-from/7521/2 "2020-03-22T21:47:23Z")

</div>

You mean a form? And it should go back to showing whatever field you just edited? What if you change multiple fields?

---

<div class="post-metadata">

**Author:** ![dreamingmind](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dreamingmind/32/1857_2.png) [@dreamingmind](https://discourse.cakephp.org/u/dreamingmind)\
**Post date:** [March 22, 2020, 10:33pm UTC](https://discourse.cakephp.org/t/redirect-the-user-to-the-exact-same-spot-within-a-page-where-s-he-previously-left-off-from/7521/3 "2020-03-22T22:33:12Z")

</div>

You will want to have HTML tags with `id` attributes at the various return points in your page. And the `action` attribute for the form you are submitting will need to include the id anchor you want to return to after submitting.

This is a pretty unusual page behavior, but technically possible.

From your description it sounds like you have a series of forms:

```auto
<form action="url#anchor1">
// form inputs here
// submit button
</form>

<form action="url#anchor2" id="anchor1">
// form inputs here
// submit button
</form>

<form action="url#anchor3" id="anchor2">
// form inputs here
// submit button
</form>

```

Now when each form gets submitted, the url (and so the Request object in your application) will include the name of the point on the page you want to go to.

You can see the idea of url anchors in the url:

[https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method](https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method)

The part after the # symbol is the id of an element on the page (in this case an h3 tag)

```auto
<h3>The Change Method<a class="headerlink" href="#the-change-method" title="Permalink to this headline">¶</a></h3>

```

Ah, but i see the modern usage may be ‘href’ rather than ‘id’ though both should work.
