Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sander Kvenild
DCST1007 - OOP
Commits
6c0ae09c
Commit
6c0ae09c
authored
Feb 02, 2022
by
Sander Kvenild
Browse files
Made checkbox setup into loop
Commented code
parent
f4212f68
Changes
1
Hide whitespace changes
Inline
Side-by-side
js-ov12-oop2-sander-kvenild/index.js
View file @
6c0ae09c
// 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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment