Form attributes: action, method, name in html

Form attributes: action, method, name in html

To control and manage the form developed or created in an HTML web page, the form contains many attributes which are used in the created HTML form through get and post methods action. When offline form information and data is moved or uploaded to the online server, then the HTML form web page uses get and post form attributes and methods.

Form attributes: action, method, name in html

So, let’s understand the action, method and name of the major form attributes in an HTML form.

Form action attribute.

use – Form action adds the URL website server address or location where the web user submits the HTML form field data and information to move or receive the form data on the dedicated server. In form purpose, the web browser knows where to send the offline processed form field data for processing, e.g., (server-side script or API endpoint location). Form action moves or uploads all the digital data and information stored in the form fields created by the web developer to a dedicated host server location via the form URL.

Send data example in HTML web page.

<form action=”/submit-form” method=”post”>

<!– Write form field element here –>

</form>

Sending data to an API endpoint.

<form action=”https://api.url .com/submit” method=”post”>

<!– Write form field element here –>

</form>

form method attribute – Method attributes in HTML web page indicates the URL HTTP method in the website, where form method is used to tell the web browser to submit the form data filled by the user to the online web server location, form method indicates how the form data is moved to the online host server.

Form method value.

  • Form GET method – HTML web page stores user query data information in the form in the form of URL through syntax. Get method in HTML web page is used to get or receive data and information from online user.
  • Form POST Method – HTML web page moves user created form data and information online through web URL HTTP request to dedicated web server. POST method is used to send online data to web server, remember, in POST method received form user data is stored and processed for future purpose.

Form Get Method Example in HTML Web Page.

<form action=”/search” method=”get”>

<input type=”text” name=”userdata” placeholder=”data”>

<input type=”submit” value=”data”>

</form>

Form Post Method Example in HTML Web Page.

<form action=”/submit” method=”post”>

<input type=”text” name=”name” placeholder=”name”>

<input type=”text” name=”email” placeholder=”email”>

<input type=”password” name=”password” placeholder=”Password”>

<input type=”submit” value=”Sign in”>

</form>

Form name attribute.

Form name attributes indicate the form name attributes of an online form. Form name attributes are used to identify form field elements when submitting an HTML web page with web scripts. Form name attributes feature JavaScript and other popular server-side script languages ​​to indicate the form and allow custom changes to the form.

Form name attributes example.

<form name=”contactForm” action=”/submit” method=”post”>

<input type=”text” name=”yourname” placeholder=”Enter Your Name”>

<input type=”email” name=”email” placeholder=”Your Email”>

<input type=”submit” value=”Submit”>

</form>

Form Attributes Explanation in HTML web page.

  • Form Action – HTML form indicates the website URL location in the web page, where user created form data and information is sent online.
  • Form Method – It indicates the send data order in the HTML form web page, where online user filled data is moved, in HTML form methods get and post method is used to get the online form data i.e. receive and post i.e. upload data and information to the server.