THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

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

Property
value Yes Yes Yes Yes Yes

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