Input Checkbox value Attribute

Definition and Usage

value Set or return the value of the 'value' attribute of the checkbox.

For checkboxes, the content of the 'value' attribute does not appear in the user interface. The 'value' attribute is only meaningful when submitting the form. If the checkbox is checked when the form is submitted, the name of the checkbox and the value of the 'value' attribute are sent together (if the checkbox is not checked, no information is sent).

See also:

HTML Reference Manual:HTML <input> value Attribute

Example

Example 1

Return the value of the 'value' attribute of the checkbox:

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

Try it yourself

Example 2

Change the value associated with the checkbox:

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

Try it yourself

Example 3

Submit the 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 has been changed. Try submitting the form again.";

Try it yourself

Grammar

Return value attribute:

checkboxObject.value

Set value attribute:

checkboxObject.value = text

Attribute Value

Value Description
text Specifies the value associated with the input (also the value sent when submitted).

Technical Details

Return value: String value, representing the value of the checkbox's value attribute.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support