Commit 97ce860c authored by Sander Kvenild's avatar Sander Kvenild
Browse files

Added functionality to second button

parent 83bbbf94
......@@ -29,12 +29,8 @@
<th>Startverdi</th>
</tr>
<tr>
<td>
<input type="text" id="kundenummer1" value="12345678">
</td>
<td>
<input type="text" id="navn1" value="Kari Hansen">
</td>
<td>12345678</td>
<td>Kari Hansen</td>
<td>
<input type="checkbox" name="check" id="type1">
</td>
......@@ -43,12 +39,8 @@
</td>
</tr>
<tr>
<td>
<input type="text" id="kundenummer2" value="24681632">
</td>
<td>
<input type="text" id="navn2" value="Lise Jensen">
</td>
<td>24681632</td>
<td>Lise Jensen</td>
<td>
<input type="checkbox" name="check" id="type2" checked>
</td>
......@@ -57,12 +49,8 @@
</td>
</tr>
<tr>
<td>
<input type="text" id="kundenummer3" value="16777216">
</td>
<td>
<input type="text" id="navn3" value="Petter Olsen">
</td>
<td>16777216</td>
<td>Petter Olsen</td>
<td>
<input type="checkbox" name="check" id="type3">
</td>
......
......@@ -2,7 +2,7 @@ class konto {
constructor (kundenummer, kundenavn, saldo = 0) {
this.kundenummer = kundenummer;
this.kundenavn = kundenavn;
this.saldo = saldo;
this.saldo = Number(saldo);
}
innskudd(verdi) {
......@@ -27,8 +27,7 @@ class konto {
class barnekonto extends konto {
constructor (kundenummer, kundenavn) {
super(kundenummer, kundenavn)
this.saldo = 200;
super(kundenummer, kundenavn, 200)
}
}
......@@ -61,25 +60,45 @@ function tre_kontoer() {
print(`17:30: ${kari.infoLite()}`);
}
function tre_kontoer_input() {
output.innerText = "";
// TODO: blir dette for kryptisk?
let kari = !checkboxes[0].checked ? new konto(24681632, "Kari Hansen", saldos[0].value): new barnekonto(24681632, "Kari Hansen");
let lise = !checkboxes[1].checked ? new konto(12345678, "Lise Jensen", saldos[1].value): new barnekonto(12345678, "Lise Jensen");
let petter = !checkboxes[2].checked ? new konto(16777216, "Petter Olsen", saldos[2].value): new barnekonto(16777216, "Petter Olsen");
kari.uttak(300);
print(`10:30: ${kari.infoLite()}`);
lise.innskudd(4000);
print(`11:00: ${lise.infoLite()}`);
petter.innskudd(3000);
print(`11:00: ${petter.infoLite()}`);
kari.uttak(250);
petter.innskudd(250);
print(`12:15: ${kari.infoLite()}`);
print(`12:15: ${petter.infoLite()}`);
kari.uttak(800);
print(`17:30: ${kari.infoLite()}`);
}
let saldos = document.getElementsByName("saldo");
let checkboxes = document.getElementsByName("check");
// TODO: Convert to loop
checkboxes[0].onchange = () => {
saldos[0].disabled = checkboxes[0].checked;
if (checkboxes[0].checked) {
saldos[0].value = 200;
}
saldos[0].value = checkboxes[0].checked ? 200: 0;
}
checkboxes[1].onchange = () => {
saldos[1].disabled = checkboxes[1].checked;
if (checkboxes[1].checked) {
saldos[1].value = 200;
}
saldos[1].value = checkboxes[1].checked ? 200: 0;
}
checkboxes[2].onchange = () => {
saldos[2].disabled = checkboxes[2].checked;
if (checkboxes[2].checked) {
saldos[2].value = 200;
}
saldos[2].value = checkboxes[2].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