Home >Web Front-end >JS Tutorial >JavaScript method to obtain web form submission method_javascript skills
The example in this article describes the method of using JavaScript to obtain the web form submission method. Share it with everyone for your reference. The details are as follows:
JavaScript obtains whether the submission method of a web form is get or post. Obtaining the submission method can be obtained through the method attribute of the form
<!DOCTYPE html> <html> <body> <form id="frm1" action="form_action.asp" method="get"> First name: <input type="text" name="fname" value="Donald"><br> Last name: <input type="text" name="lname" value="Duck"><br> <input type="submit" value="Submit"> </form> <p>The method for sending form-data is: <script> document.write(document.getElementById("frm1").method); </script> </p> </body> </html>
The running results are as follows:
The method for sending form-data is:get
I hope this article will be helpful to everyone’s JavaScript programming design.