HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Hidden value Property

Hidden Object Reference Hidden Object

Example

Return 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

Internet Explorer Firefox Opera Google Chrome Safari

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


Hidden Object Reference Hidden Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE