Latest web development tutorials
 

Input Hidden value Property

< Input Hidden Object

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:

w3ii
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

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