- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Input Hidden name Property
The HTML DOM input hidden name property returns and alter the value of name attribute of input field of type=”hidden” in an HTML document.
Syntax
Following is the syntax −
1. Returning name
object.name
2. modifying name
object.name=”text”
Example
Let us see an example of HTML DOM input hidden name property −
<!DOCTYPE html> <html> <head> <style> body{ text-align:center; background-color:#F19A3E; color:#fff; } .btn{ background-color:#3C787E; border:none; height:2rem; border-radius:50px; width:60%; margin:1rem auto; display:block; color:#fff; outline:none; } .show{ color:#fff; font-size:1.2rem; font-weight:600; } </style> </head> <body> <h1>DOM Hidden name Property Example</h1> Enter your Name: <input type="hidden" class="input-field" name="Hi_I'm_hidden_input_field"> <button onclick="getName()" class="btn">Click to get name of hidden input field</button> <div class="show"></div> <script> function getName() { var inputField = document.querySelector(".input-field"); var msgDiv= document.querySelector(".show"); msgDiv.innerHTML=inputField.name; } </script> </body> </html>
Output
This will produce the following output −
Now, click on “blue” button to get the value of name attribute of hidden input field.
Advertisements