W3Schools.com

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 type="text/javascript">
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
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
Premium Website Design
WEB BUILDING
Download XML Editor
FREE Website BUILDER
Best Website Templates Top CSS Templates
CREATE HTML Websites
EASY WEBSITE BUILDER
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE