42 lines
1.9 KiB
HTML
42 lines
1.9 KiB
HTML
|
<!DOCTYPE html>
|
||
|
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>Калькулятор</title>
|
||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
|
||
|
<div class="m-auto dflex flex-row align-items-center">
|
||
|
<div class="col-sm-3 my-1">
|
||
|
<input type="number" class="form-control" id="num1">
|
||
|
</div>
|
||
|
<div class="col-sm-3 my-1">
|
||
|
<select class="form-control" id="operation">
|
||
|
<option value="sum" selected>+</option>
|
||
|
<option value="sub">-</option>
|
||
|
<option value="mul">*</option>
|
||
|
<option value="div">/</option>
|
||
|
</select>
|
||
|
</div>
|
||
|
<div class="col-sm-3 my-1">
|
||
|
<input type="number" class="form-control" id="num2">
|
||
|
</div>
|
||
|
<div class="col-sm-3 my-1">
|
||
|
<button type="button" class="form-control btn btn-light" id="get-result" onclick="calculate()">=</button>
|
||
|
</div>
|
||
|
<div class="col-sm-3 my-1">
|
||
|
<p class="h5" id="result"></p>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<script>
|
||
|
async function calculate() {
|
||
|
const num1 = document.getElementById("num1").value
|
||
|
const num2 = document.getElementById("num2").value
|
||
|
document.getElementById("result").innerHTML = await (await fetch(`http://127.0.0.1:8080/${document.getElementById("operation").value}?num1=${num1}&num2=${num2}`)).text()
|
||
|
}
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|