Input Hidden value Property
Example
Get the value of the value attribute of a hidden input field:
var x = document.getElementById("myInput").value;
The result of x will be:
W3Schools
Try it yourself »
Definition and Usage
The value property sets or returns the value of the value attribute of the hidden input field.
The value attribute defines the default value of the hidden input field.
Browser Support
The value property is supported in all major browsers.
Syntax
Return the value property:
hiddenObject.value
Set the value property:
hiddenObject.value=text
Property Values
Value | Description |
---|---|
text | Specifies the initial (default) value of the input field |
Technical Details
Return Value: | A String, representing the value of the value attribute of the hidden input field |
---|
More Examples
Example
Change the value of the hidden field:
document.getElementById("myInput").value = "USA";
Try it yourself »
Example
Submitting a form - How to change the value of the hidden field:
document.getElementById("myInput").value = "USA";
document.getElementById("demo").innerHTML = "The value of the value attribute
was changed. Try to submit the form again.";
Try it yourself »
Related Pages
HTML reference: HTML <input> value attribute
Input Hidden Object