Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

What does action="#" do?

In the code below... what does the fom action="#" do?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0  Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
     <title>Adding Nodes</title>
     <script type="text/javascript" language="Javascript" src="script01.js">
     </script>
</head>
<body>
<form action="#">
     <p><textarea id="textArea" rows="5" cols="30"></textarea></p>
     <input type="submit" value="Add some text to the page" />
</form>
</body>
</html>
0
Mike Johnson
Asked:
Mike Johnson
  • 2
1 Solution
 
b0lsc0ttCommented:
uksub,

It basically is used to just provide an entry for the action attribute so the page will validate and so browser will not enter quirks mode.  The number sign (#) is used to go to a named anchor.  Since no page name is before it and there is not anchor name after it nothing will happen because of that property.  The actual submit is probably done with javascript.  A browser that doesn't support javascript or has it disabled would just "submit the form to itself" and nothing would happen.

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
DonKylesCommented:
In this case, it does nothing.
Form action will perform when you click on submit button. Action will tell where to go/what to do after submission.

for example
<form name="form1" method="post" action="update.asp" onSubmit="return checkInput();">

after the submission, this form will execute javascript code before redirect to update.asp file.
0
 
HonorGodCommented:
 You have encountered an ugliness of Javascript closely bound with HTML.
It would be best if we had a clear separation of

- presentation - (controlled/defined by CSS)
- behavior      - (JavaScript)
- structure      - (HTML)

  A number of proponents (strongly) suggest that JavaScript be unobtrusive.

  What you have does not match the guidelines of separation.
0
 
b0lsc0ttCommented:
I'm glad that I could help you.  I noticed the B grade.  Did you still have some question or need some help with this?  If so, let us know.  I'm certainly interested in helping as you need it.  It is nice to have a chance to earn an A.

Thanks for the fun question.

bol
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now