-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
47 lines (40 loc) · 1.54 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Taschenrechner</title>
</head>
<body>
<h1>Taschenrechner</h1>
<form id="calculatorForm">
<label for="num1">Nummer 1:</label>
<input type="number" id="num1" name="num1" required>
<label for="num2">Nummer 2:</label>
<input type="number" id="num2" name="num2" required>
<label for="operation">Operation:</label>
<select id="operation" name="operation" required>
<option value="add">Addition</option>
<option value="sub">Subtraktion</option>
<option value="mul">Multiplikation</option>
<option value="div">Division</option>
</select>
<button type="button" onclick="calculate()">Ergebnis</button>
</form>
<h2>Ergebnis: <span id="result"></span></h2>
<script>
function calculate() {
const num1 = document.getElementById('num1').value;
const num2 = document.getElementById('num2').value;
const operation = document.getElementById('operation').value;
fetch(`http://localhost:3000/${operation}/${num1}/${num2}`)
.then(response => response.json())
.then(data => {
document.getElementById('result').innerText = data.result;
})
.catch(error => console.error('Error:', error));
}
</script>
</body>
</html>