Search w3schools.com:

SHARE THIS PAGE

Checkbox value Property

Checkbox Object Reference Checkbox Object

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 with along with the value of the value property (if the checkbox is not checked, no information is sent).

Syntax

Set the value property:

checkboxObject.value="value"

Return the value property:

checkboxObject.value


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The value property is supported in all major browsers.


Example

Example

Display the value associated with the checkbox:

<html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("bike").value;
alert(x);
}
</script>
</head>
<body>

<form>
<input type="checkbox" id="bike" value="Bike"> I have a bike<br>
</form>

<button type="button" onclick="displayResult()">Display value</button>

</body>
</html>

Try it yourself »


Checkbox Object Reference Checkbox Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]