2023-04-11 12:02:52 +04:00

45 lines
1.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>