- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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.