and
? I am reading a book about html development (which Iโ€™m pretty new to), and alth...">

What do <form action = "#"> and <form method = "post" action = "#">?

I am reading a book about html development (which Iโ€™m pretty new to), and although the book just published it 1 month ago (November 2011), the author is an experienced coder and maybe using # to act on the form is old school?

Because I'm trying to get the gist of the sample code, and I can not find an explanation of form action="#" , despite the search

 <form action="#"> 

google, SO and www.w3schools.com.

Does anyone know what the # action means for forms?

+59
html
Dec 06 '11 at 4:14
source share
4 answers

The action usually indicates the file / page to which the form is submitted (using the method described in the paramater method (post, get, etc.))

The # action indicates that the form stays on one page, just the url suffix with # . Similar use occurs in anchors. <a href=#">Link</a> , for example, will remain on one page.

Thus, the form is sent to the same page, which then processes the data, etc.

+65
Dec 06 '11 at 4:17
source share

action="" the page address will be resolved. action="#" address of the page + # will be resolved, which will mean the empty identifier of the fragment.

The execution of the latter may prevent navigation (new loading) on โ€‹โ€‹the same page and instead try to go to the element with the identifier in the fragment identifier. But, since it is empty, it will not jump anywhere.

Typically, authors simply put # in href-like attributes when they will not use the attribute, where they use scripts. In these cases, they could simply use action="" (or omit it if validation allows).

+22
Dec 06 '11 at 4:23
source share

Obviously, an โ€œactionโ€ was required before HTML5 (and # was just a stand), but you no longer need to use it. - https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Sending_and_retrieving_form_data

+6
Jun 15 '16 at 23:01
source share

The # tag allows you to send data to the same file. I see this as a three-step process:

  • Request a database to populate from
  • Allow user to modify form data
  • Re-submit data to the database via PHP script

Using the method = '#' you can do it all in the same file.

After the send request is complete, the page will reload with updated data from the database.

+3
Jul 19 '14 at 2:33
source share



All Articles