Input Checkbox value Property
Example
Return the value of the value attribute of a checkbox:
The result of x will be:
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:
Set the value property:
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:
Example
Submitting a form - how to change the value associated with the checkbox:
document.getElementById("demo").innerHTML = "The value of the value attribute was changed. Try to submit the form again.";
Related Pages
HTML reference: HTML <input> value attribute
Input Checkbox Object