Input Hidden value Property
Example
Get the value of the value attribute of a hidden input field:
var x = document.getElementById("myInput").value;
Try it Yourself »
Description
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
Property | |||||
---|---|---|---|---|---|
value | Yes | Yes | Yes | Yes | Yes |
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
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.