- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Set where to send the form-data when a form is submitted in HTML?
When a form is submitted, the input control's processing file's URL is specified using the HTML <input> formaction property. The formaction attribute is invoked when the form has been submitted. After submitting the form, the form's data must be delivered to the server.
Following are the examples…
Example: Using method = “post”
In the following example we are submitting the form using method=”post”
<!DOCTYPE html> <html> <body> <FORM action="https://www.tutorialspoint.com/index.htm" method="post"> <P> <LABEL for="firstname">First name: </LABEL> <INPUT type="text" id="firstname"><BR> <LABEL for="lastname">Last name: </LABEL> <INPUT type="text" id="lastname"><BR> <LABEL for="email">email: </LABEL> <INPUT type="text" id="email"><BR> <INPUT type="radio" name="sex" value="Male"> Male<BR> <INPUT type="radio" name="sex" value="Female"> Female<BR> <INPUT type="submit" value="Send"> <INPUT type="reset"> </P> </FORM> </body> </html>
Output
When the script is executed, it will display the input types of first name, last name,email and radio buttons for male and female, along with a send and reset button. When we click on the send button, the form gets submitted.
Example: Using method = “get”
In the following example we are submitting the form using method=”get”
<!DOCTYPE html> <html> <body> <form action="https://www.tutorialspoint.com/index.htm" method="get" target="_blank"> <label for="fname">First name:</label> <input type="text" id="fname" name="fname"><br><br> <label for="lname">Last name:</label> <input type="text" id="lname" name="lname"><br><br> <input type="submit" value="Submit"> </form> </body> </html>
Output
On executing the above script, it will display an input type field containing firstname , last name, along with a submit button .When we click on the submit button, the form gets submitted.
- Related Articles
- How to specify where to send the form-data when a form is submitted in HTML?
- How to prevent form from being submitted?
- How to get a key/value data set from a HTML form?
- How to specify the HTTP method to use when sending form-data in HTML?
- Set the text wrap in a form in HTML
- How to set that the text direction will be submitted in HTML?
- Set the name of the form the element belongs to in HTML?
- Execute a script when a reset button in a form is clicked in HTML?
- Set the character encodings that are used for form submission in HTML
- How to specify that the form should not be validated when disabled in HTML?
- HTML Design Form
- HTML form Attribute
- How to reload the current page without losing any form data with HTML?
- What does enctype='multipart/form-data' mean in HTML?
- How to set whether the dragged data is copied, moved, or linked, when dropped in HTML?
