This commit is contained in:
2020-01-29 12:56:06 +01:00
commit 04efff0d15
51 changed files with 1673 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Oppgave 11</title>
<link rel="stylesheet" href="../../../../resources/css/main.css">
<script async src="./script.js"></script>
</head>
<body>
<h1>Oppgave 11</h1>
<div class=center>
<div class="inline">
Lag <input type="number" id="amount" value="0" min="0" max="999"> tilfeldige tall mellom 0 og <input type="number" id="range" value="0" min="0">
<button id="reload">Reload</button>
</div>
<table id="table">
<thead>
<tr>
<th>Tall</th>
</tr>
</thead>
</table>
</div>
</body>
</html>

View File

@@ -0,0 +1,34 @@
const table = document.getElementById("table");
const globalAmount = document.getElementById("amount");
const globalRange = document.getElementById("range");
const reloadButton = document.getElementById("reload");
const listHeader = table.innerHTML;
globalAmount.addEventListener("input", updateList, false);
globalRange.addEventListener("input", updateList, false);
reloadButton.addEventListener("click", updateList, false);
function updateList() {
addToList(generateNums(globalAmount.value, globalRange.value), table);
}
function addToList(numArray, table) {
rows = '';
for (i in numArray) {
rows += '<tr><td>' + numArray[i] + '</td></tr>';
}
table.innerHTML = listHeader + rows;
}
function generateNums(amount, range) {
let array = [];
for (i=0; i<amount; i++) {
array[i] = Math.ceil(Math.random()*range);
}
return array;
}
function sumTable(table) {
}