JSFiddle - React, Tailwind, and code Playground
by Qwerty_Wasd
HTML
<h1></h1>
<form align=center name="Form">
<p>Введите вес енота(в килограммах):</p> <input type=text name="weight"><br>
<p>Введите возраст енота(В месяцах):</p> <input type=text name="age"><br>
<p>Введите пол енота(1-мальчик, 0-девочка):</p> <input type=text oninput="change()" name="sex"><br>
<p>Суточная норма каллорий:</p> <input type=text name="callories"><br>
<input type="reset" value="Очистить" onclick="reset()">
</form>
<script>
function change() {
let weight = document.querySelector("[name='weight']"),
age = document.querySelector("[name='age']"),
callories = document.querySelector("[name='callories']");
if(+this.value) {
callories.value = +weight.value * 9.99 + 4.92 * +age.value / 12 + 5
} else {
callories.value = +weight.value * 9.99 + 4.92 * +age.value / 12 - 161
}
}
</script>