admin管理员组

文章数量:1391798

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.

本文标签: phpwhat is meant by actionquotmainbodyquot in a HTML formStack Overflow