Latest web development tutorials

HTML DOM Checkbox value property

Checkbox Object Reference Checkbox objects

Definition and Usage

value property sets or returns the value of the property value checkbox.

value the property value check box is not displayed in the user interface. value attribute for form data submitted (only selected check box will pass data to the server, if nothing is selected check box is not passing data).

grammar

Set the value property:

checkboxObject.value="value"

Returns the value property:

checkboxObject.value


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support attribute value


Examples

Examples

Display the value of the check box associated with:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
    var x=document.getElementById("bike").value;
    alert(x);
}
</script>
</head>
<body>

<form>
<input type="checkbox" id="bike" value="Bike"> 我有一辆自行车 <br>
</form>
<button type="button" onclick="displayResult()">显示value值</button>

</body>
</html>

try it"


Checkbox Object Reference Checkbox objects