最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - what is meant by action="#main_body" in a HTML form - Stack Overflow

programmeradmin1浏览0评论

I have form and some fields and I want send these fields to the next page via done.php using action="#main_body".

What are the differences between these two forms?

<form id="formElem" name="formElem" action="/ifs/form/index.php" method="post">

<form id="formElem " class="ifs"  method="post" action="#main_body">

I have form and some fields and I want send these fields to the next page via done.php using action="#main_body".

What are the differences between these two forms?

<form id="formElem" name="formElem" action="/ifs/form/index.php" method="post">

<form id="formElem " class="ifs"  method="post" action="#main_body">
Share Improve this question edited Aug 1, 2012 at 8:00 hakre 198k55 gold badges449 silver badges856 bronze badges asked Jan 2, 2012 at 10:19 user1122910user1122910 1173 silver badges15 bronze badges 1
  • Unless your form is part of done.php, use action="path/to/done.php". – Herbert Commented Jan 2, 2012 at 10:34
Add a ment  | 

3 Answers 3

Reset to default 6

The plete action of the form is the URL of the page containing the form at the time of loading the form + the hashtag. So submitting the form will load the same page, but with a ahashtag (anchor) of #man_body. This is a side effect of action attributes being realtive if not definitly given as absolute.

Please be aware, that it is browser-dependant and header-dependant wether the page will actually reload or just scroll.

in the first case you send the values of your inputs to a specific page called done.php. In the second way you're calling the same page in which you have your form (plus an hashtag)

In the second link you are calling the same page with a hashtag of "main_body". it will work something like a 'TOP' link provided in lengthy pages which scrolled back to top of the page. a difference is here the page will scroll(or reload) to "main_body" when you submit the form.

发布评论

评论列表(0)

  1. 暂无评论