I want to make a webpage that, when you click, it adds a point. I also want that, when A checkbox is checked, each click adds 5 points. I tried this code, but it doesn't seem to be working:
<!DOCTYPE html>
<html>
<head>
<title>Click to add points!</title>
<script type="text/javascript">
var hey = 3;
var points = 0;
function addPoint(number)
{
points = points + number;
document.getElementById("points").innerHTML = points;
};
function checkBox()
{
var chkBox = document.getElementById("extraPoints").checked;
}
</script>
</head>
<html onclick="
checkBox();
if (chkBox == true)
{
addPoint(5);
}
else
{
addPoint(1);
}">
<body>
<p align="center">Points: <span id="points">0</span></p>
<p align="center"><input type="checkbox" id="extraPoints" /></p>
<p id="writeHere"></p>
</body>
</html>
I would also like to point out that I can't use jQuery. Thank you in advance.