Javascript examples for DOM HTML Element:Input Text
Input Text name Property - Change the name of a text field:
<!DOCTYPE html> <html> <body> Username: <input type="text" id="myText" name="usrnm"> <button onclick="display()">Display name</button> <button onclick="change()">Change name</button> <script> function display() { var x = document.getElementById("myText").name; console.log("The name of the text field is: " + x); } function change() {//w w w .ja v a 2 s.c om var x = document.getElementById("myText").name = "username"; console.log("The name was changed to: " + x); } </script> </body> </html>