Javascript examples for DOM HTML Element:Input Submit
The name property sets or gets the name attribute of a submit button.
Set the name property with the following Values
Value | Description |
---|---|
name | Sets the name of the submit button |
A String, representing the name of the submit button
The following code shows how to get the value of the name attribute of a Submit button:
<!DOCTYPE html> <html> <body> <input type="submit" name="submit1" id="mySubmit"> <button onclick="display()">Display name</button> <button onclick="change()">Change name</button> <script> function display() { var x = document.getElementById("mySubmit").name; console.log("The name of the Submit button is: " + x); } function change() {//from w w w .j a v a 2s . c o m var x = document.getElementById("mySubmit").name = "newName"; console.log("The name was changed to: " + x); } </script> </body> </html>