-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUntitled-1.html
More file actions
38 lines (38 loc) · 1.36 KB
/
Untitled-1.html
File metadata and controls
38 lines (38 loc) · 1.36 KB
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
<html>
<head>
<title>Kalkulator</title>
<script>
function calculate(){
var a = parseFloat(document.getElementById("number1").value);
var b = parseFloat(document.getElementById("number2").value);
var op = document.getElementById("operator").value;
var calculate;
if (op == "add") {
calculate = a + b;
} else if (op == "min") {
calculate = a - b;
} else if (op == "div") {
calculate = a / b;
} else if (op == "mul") {
calculate = a * b;
}
document.getElementById("result").innerHTML = calculate;
}
</script>
</head>
<body>
<h2>Kalkulator</h2>
<form>
<input type="number" id="number1" placeholder="Wprowadź pierwszą liczbę"/>
<select id="operator">
<option value="add">Dodawanie</option>
<option value="min">Odejmowanie</option>
<option value="div">Dzielenie</option>
<option value="mul">Mnożenie</option>
</select>
<input type="number" id="number2" placeholder="Wprowadź drugą liczbę"/>
<input type="button" onclick="calculate()" value="Oblicz"/>
</form>
<p>Wynik: <span id="result"></span></p>
</body>
</html>