What is meant by the action = "# main_body" in the HTML form

I have a form and some fields, and I want to send these fields to the next page through done.php with action="#main_body" .

What are the differences between the two forms?

 <form id="formElem" name="formElem" action="/ifs/form/index.php" method="post"> <form id="formElem " class="ifs" method="post" action="#main_body"> 
+4
source share
3 answers

in the first case, you send the values โ€‹โ€‹of your inputs to a specific page called done.php. In the second case, you call up the same page on which you have your form (plus hashtags)

+3
source

The full form action is the URL of the page containing the form when the form + hashtags are loaded. This way, submitting the form will load the same page, but with the ahashtag (anchor) #man_body. This is a side effect effect attribute that is realistic, if not specifically defined as absolute.

Remember that it depends on the browser and depends on the page title, so that the page really reloads or just scrolls.

+6
source

In the second link, you call up the same page with the hashtag "main_body". it will work as a " TOP " link, presented on long pages that scroll back to the top of the page. the difference is here, the page will scroll (or reload) to "main_body" when the form is submitted.

+2
source

Source: https://habr.com/ru/post/1388916/


All Articles