-
Notifications
You must be signed in to change notification settings - Fork 26.7k
/
allowance-updater.html
39 lines (33 loc) · 961 Bytes
/
allowance-updater.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Allowance updater example</title>
</head>
<body>
<label for="shopping-check">Has the shopping been done? </label>
<input type="checkbox" id="shopping-check">
<p></p>
<script>
const checkBox = document.querySelector('input');
const para = document.querySelector('p');
let shoppingDone = false;
checkBox.addEventListener('change', () => {
checkBox.disabled = true;
shoppingDone = true;
updateAllowance();
});
function updateAllowance() {
let childsAllowance;
if (shoppingDone === true) {
childsAllowance = 10;
} else {
childsAllowance = 5;
}
para.textContent = `Child has earned \$${childsAllowance} this week.`;
}
updateAllowance();
</script>
</body>
</html>