Javascript examples for DOM HTML Element:Select
Select name Property - Change the value of the name attribute of a drop-down list:
<!DOCTYPE html> <html> <body> <form> <select name="selectName" id="mySelect"> <option>CSS</option> <option>HTML</option> <option>SQL</option> <option>Javascript</option> </select>/*ww w .j a v a2 s . c o m*/ </form> <button onclick="display()">Display name</button> <button onclick="change()">Change name</button> <script> function display() { var x = document.getElementById("mySelect").name; console.log("The name of the dropdown list is: " + x); } function change() { var x = document.getElementById("mySelect").name = "newName"; console.log("The name was changed to: " + x); } </script> </body> </html>