IP_Zargarov_M.A._PIbd-23/frontend/index.html

45 lines
1.8 KiB
HTML
Raw Normal View History

2023-04-11 12:02:52 +04:00
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Манипуляции с числами</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
</head>
<body>
<article class="container align-content-center">
<div class="row">
<div class="col-md-2 m-2 p-0">
<select class="form-control" id="operation">
<option value="doExp" selected>Возведение в квадрат</option>
<option value="doSin">Вычисление синуса</option>
<option value="doAbs">Модуль числа</option>
<option value="doRand">Случайное число</option>
</select>
</div>
<div class="col-md-2 m-2 p-0">
<input type="number" class="form-control" id="num">
</div>
<div class="col-md-3 m-2 p-0">
<button type="button" class="form-control btn btn-info" onclick="manipulation()">Вывести результат</button>
</div>
<div class="col-md-2 m-2 p-0 align-middle">
<p class="h4" id="result"></p>
</div>
</div>
</article>
<script>
async function manipulation() {
const num = document.getElementById("num").value
const oper = document.getElementById("operation").value
var url = `http://127.0.0.1:8080/${oper}?val=${num}`
const responce = await fetch(url)
const resout = await responce.text()
document.getElementById("result").innerHTML = resout
}
</script>
</body>