Checkbox valueProperty
Checkbox Object
Definition and Usage
The value property sets or returns the value of the value attribute of the checkbox.
The value of the checkbox's value attribute is not displayed in the user interface. The value attribute is used for form data submission (only selected checkboxes transmit data to the server; if none are selected, no checkbox data is transmitted).
Syntax
Set the value property:
checkboxObject.value="value"
Return the value property:
checkboxObject.value
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the value property.
Example
Example
Display the value associated with the checkbox:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<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 bicycle <br>
</form>
<button type="button" onclick="displayResult()">Display value</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<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 bicycle <br>
</form>
<button type="button" onclick="displayResult()">Display value</button>
</body>
</html>
Try it Yourself »
Checkbox Object Other Extensions