Home >Web Front-end >JS Tutorial >JavaScript method to obtain web form submission method_javascript skills

JavaScript method to obtain web form submission method_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:06:131317browse

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn