Commit 6c0ae09c authored by Sander Kvenild's avatar Sander Kvenild
Browse files

Made checkbox setup into loop

Commented code
parent f4212f68
// CLASSES
class konto {
constructor (kundenummer, kundenavn, saldo = 0) {
this.kundenummer = kundenummer;
......@@ -31,7 +32,10 @@ class barnekonto extends konto {
}
}
// HTML ELEMENTS
let output = document.getElementById("output");
// FUNCTIONS
function print(string) {
output.innerText += string + "\n";
}
......@@ -62,19 +66,14 @@ function tre_kontoer_input() {
print(`17:30: ${kari.infoLite()}`);
}
// Instantly run code
let saldos = document.getElementsByName("saldo");
let checkboxes = document.getElementsByName("check");
// TODO: Convert to loop
checkboxes[0].onchange = () => {
saldos[0].disabled = checkboxes[0].checked;
saldos[0].value = checkboxes[0].checked ? 200: 0;
}
checkboxes[1].onchange = () => {
saldos[1].disabled = checkboxes[1].checked;
saldos[1].value = checkboxes[1].checked ? 200: 0;
}
checkboxes[2].onchange = () => {
saldos[2].disabled = checkboxes[2].checked;
saldos[2].value = checkboxes[2].checked ? 200: 0;
// Set checkboxes to change saldos
for (let i = 0; i < checkboxes.length; i++) {
checkboxes[i].onchange = () => {
saldos[i].disabled = checkboxes[i].checked;
saldos[i].value = checkboxes[i].checked ? 200: 0;
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment