Home >Web Front-end >JS Tutorial >Javascript method to get form name (name)_javascript skills
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.