Home >Web Front-end >JS Tutorial >Javascript method to get form name (name)_javascript skills

Javascript method to get form name (name)_javascript skills

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

The example in this article describes the method of obtaining the form name (name) in Javascript. Share it with everyone for your reference. The details are as follows:

The following code obtains the form name through the name attribute of the form

<!DOCTYPE html>
<html>
<body>
<form id="frm1" name="form1">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
</form>
<p>The name of the form is:
<script>
document.write(document.getElementById("frm1").name);
</script>
</p>
</body>
</html>

The results of running the above code are as follows:

The name of the form is:form1

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