SoFunction
Updated on 2025-02-28

Javascript method to get form name (name)

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

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

<!DOCTYPE html>
<html>
<body>
<form  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>
(("frm1").name);
</script>
</p>
</body>
</html>

The above code run results are as follows:

The name of the form is:form1

I hope this article will be helpful to everyone's JavaScript programming.