Javascript examples for DOM HTML Element:Input Hidden
The value property sets or gets the value attribute of the hidden input field.
Set the value property with the following Values
Value | Description |
---|---|
text | Sets the default value of the input field |
A String, representing the value of the value attribute of the hidden input field
The following code shows how to get the value of the value attribute of a hidden input field:
<!DOCTYPE html> <html> <body> <form action="#"> A hidden field:<input type="hidden" id="myInput" name="country" value="Norway"><br> <input type="submit" value="Submit"> </form>/*from ww w . jav a2s . c o m*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var v = document.getElementById("myInput").value; document.getElementById("demo").innerHTML = v; } </script> </body> </html>