2024-08-26 13:59:21 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
2024-08-26 14:39:13 +02:00
|
|
|
|
2024-08-26 13:59:21 +02:00
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Intro</title>
|
|
|
|
</head>
|
2024-08-26 14:39:13 +02:00
|
|
|
|
2024-08-26 13:59:21 +02:00
|
|
|
<body>
|
|
|
|
<div class="group">
|
|
|
|
<div>Hei jeg heter</div>
|
2024-08-26 14:39:13 +02:00
|
|
|
<div id="namediv">...her kommer et navn<br></div>
|
2024-08-26 13:59:21 +02:00
|
|
|
</div>
|
|
|
|
<div class="group">
|
|
|
|
<div>Jeg bor i</div>
|
2024-08-26 14:39:13 +02:00
|
|
|
<div id="placediv">..her kommer et sted<br></div>
|
2024-08-26 13:59:21 +02:00
|
|
|
</div>
|
|
|
|
<div class="group">
|
|
|
|
<div>Min favorittmat er</div>
|
2024-08-26 14:39:13 +02:00
|
|
|
<div id="fooddiv">...her kommer en matrett<br></div>
|
2024-08-26 13:59:21 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<button onclick="setFields()">Klikk her for å sett inn verdier</button>
|
2024-08-26 14:39:13 +02:00
|
|
|
Navn: <input type="text" onchange="setName(this.value)">
|
|
|
|
Sted: <input type="text" onchange="setPlace(this.value)">
|
|
|
|
Mat: <input type="text" onchange="setFood(this.value)">
|
2024-08-26 13:59:21 +02:00
|
|
|
|
|
|
|
<script>
|
2024-08-26 14:39:13 +02:00
|
|
|
|
|
|
|
// Model
|
2024-08-26 14:39:39 +02:00
|
|
|
let firstName;
|
2024-08-26 13:59:21 +02:00
|
|
|
let place;
|
|
|
|
let food;
|
2024-08-26 14:39:13 +02:00
|
|
|
// View
|
|
|
|
function setFields() {
|
2024-08-26 14:39:39 +02:00
|
|
|
document.getElementById("namediv").innerHTML = firstName;
|
2024-08-26 14:39:13 +02:00
|
|
|
document.getElementById("placediv").innerHTML = place;
|
|
|
|
document.getElementById("fooddiv").innerHTML = food;
|
2024-08-26 13:59:21 +02:00
|
|
|
|
|
|
|
}
|
2024-08-26 14:39:13 +02:00
|
|
|
// Controller
|
|
|
|
function setName(nameInput) {
|
|
|
|
firstName = nameInput;
|
|
|
|
setFields();
|
|
|
|
}
|
|
|
|
function setPlace(placeInput) {
|
|
|
|
place = placeInput;
|
|
|
|
setFields();
|
|
|
|
}
|
|
|
|
function setFood(foodInput) {
|
|
|
|
food = foodInput;
|
|
|
|
setFields();
|
|
|
|
}
|
2024-08-26 13:59:21 +02:00
|
|
|
</script>
|
|
|
|
<style>
|
2024-08-26 14:39:13 +02:00
|
|
|
.group {
|
2024-08-26 13:59:21 +02:00
|
|
|
display: flex;
|
2024-08-26 14:39:13 +02:00
|
|
|
padding: 1px;
|
2024-08-26 13:59:21 +02:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</body>
|
2024-08-26 14:39:13 +02:00
|
|
|
|
2024-08-26 13:59:21 +02:00
|
|
|
</html>
|