There is a form on the page that returns to the first page after submission I want it to stay on this section of the page.
CodePudding user response:
It is hard to understand what is "the page" and "this section".
Here are various approaches:
Stay on page:
<form onsubmit="event.preventDefault(); //do stuff if need">
...
</form>
Scrolling to a section:
If you have a section <section id="mySt"></section>
of either the page of the form or the previous one, you give it an id like i did. To go to it (by scrolling to it), you show that in your URL, for example http://example.org/#mySt
. That could be in form: action="somepage.php#mySt"
. Or scripting, you can use scrollIntoView
on the page you need, when you are deciding it's needed, write in js file:
// on some event
var mySt = document.getElementById('mySt');
mySt.scrollIntoView();
Have a blessed code!