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

Input Checkbox value Property

Input Checkbox Object Reference Input Checkbox Object

Example

Return the value of the value attribute of a checkbox:

var x = document.getElementById("myCheck").value;

The result of x will be:

myvalue

Try it yourself »


Definition and Usage

The value property sets or returns the value of the value attribute of a checkbox.

For checkboxes, the contents of the value property do not appear in the user interface. The value property only has meaning when submitting a form. If a checkbox is in checked state when the form is submitted, the name of the checkbox is sent along with the value of the value property (if the checkbox is not checked, no information is sent).


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The value property is supported in all major browsers.


Syntax

Return the value property:

checkboxObject.value

Set the value property:

checkboxObject.value=text

Property Values

Value Description
text Specifies the value associated with the input (this is also the value that is sent on submit)

Technical Details

Return Value: A String, representing the value of the value attribute of the checkbox


More Examples

Example

Change the value associated with the checkbox:

document.getElementById("myCheck").value = "newCheckboxValue";

Try it yourself »

Example

Submitting a form - how to change the value associated with the checkbox:

document.getElementById("myCheck").value = "newCheckboxValue";
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 Checkbox Object Reference Input Checkbox Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook