Skip to content

Instantly share code, notes, and snippets.

@olegberman
Created July 12, 2016 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olegberman/0b26c33793a0d15092ffab50fc3e2dc5 to your computer and use it in GitHub Desktop.
Save olegberman/0b26c33793a0d15092ffab50fc3e2dc5 to your computer and use it in GitHub Desktop.
Points based system calculator
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<select id="age">
<option value="1">20</option>
<option value="2">30</option>
</select>
<b id="points">Your points: </b>
<script>
window.onload = function() {
var ageSelected = document.getElementById('age');
var points = document.getElementById('points');
var result = 0;
ageSelected.addEventListener('change', function() {
if(Number(ageSelected.value) === 1) {
result = 10;
} else {
result = 20;
}
points.innerHTML = 'Your points are: ' + result;
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment