What Do <Form Action="#"> and <Form Method="Post" Action="#"> Do

what do form action= # and form method= post action= # do?

Action normally specifies the file/page that the form is submitted to (using the method described in the method paramater (post, get etc.))

An action of # indicates that the form stays on the same page, simply suffixing the url with a #. Similar use occurs in anchors. <a href=#">Link</a> for example, will stay on the same page.

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

what do form action=“.”

Form Action attribute specifies where to send the form-data when a
form is submitted

Possible accepted values:

  1. An absolute URL: points to another web site (like action="http://www.example.com/example.htm")
  2. A relative URL - points to a file within a web site (like action="example.htm")

in your case of action="." you are pointing to current url/file/directory.
So it will reload the same page on form submission.

What is form action= # ?

An action of "#" indicates that the form stays on the same page, simply suffixing the URL with a #.

What does an entry action='.' in html form mean?

. is the current path segment of the current URL. In other words, it refers to the current relative URL.

If your current URL is http://example.com/foo/bar/baz/, then . refers to http://example.com/foo/bar/baz/ (yes, same URL).

It's a bit trickier without a trailing slash. On http://example.com/foo/bar/baz, . refers to http://example.com/foo/bar/. That's why it's not usually a good idea to use .; you could use action="" instead, which means action has an empty value, in which case the current (full) URL is substituted.

This . is pretty universal and is used in many contexts involving URLs or file paths.



Related Topics



Leave a reply



Submit