Whing Dela Cruz
asked on
Check box
Hi experts, I want to get the value of the check box. Please correct code below. Thank you!
<!DOCTYPE html>
<html>
<body>
<input id="cb" type="checkbox" name="vehicle" value="Bike" checked> I have a bike<br>
<button onclick="return Get()">Check now</button>
<script>
function Get()
{
var x = document.getElementById("cb").value;
if (x.checked == true)
{
alert(x);
}
else
{
x = "No bike"
alert(x);
}
}
</script>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER