-
Notifications
You must be signed in to change notification settings - Fork 0
/
m1.html
62 lines (52 loc) · 1.81 KB
/
m1.html
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CalculandoAsKcal</title>
<style>
body{
background-color: rgb(156, 229, 229);
font: normal 14pt Arial;
}
</style>
</head>
<body>
<h1>Calculadora FIT</h1>
<p>Qual é o alimento que deseja calcular?</p>
<input type="text" name="alimento" id="alimento">
<input type="button" value="pesquisar" onclick="pesquisar()">
<div id="calculadoracalorias" style="display: none;">
<div>
<input type="number" name="gramas1" id="gramas1" placeholder="gramas">
<input type="number" name="cal1" id="cal1" placeholder="calorias">
</div>
<div>
<input type="number" name="gramas2" id="gramas2" placeholder="gramas">
<input type="number" name="cal2" id="cal2" placeholder="???" readonly>
</div>
<div>
<input type="button" value="calcular" onclick="calcular()">
</div>
<p id="resultado"></p>
</div>
<script>
var escolha = document.getElementById('oq')
var calculadoracalorias = document.getElementById('calculadoracalorias')
var cal2 = document.getElementById('cal2')
var cal1 = document.getElementById('cal1')
var gramas2 = document.getElementById('gramas2')
var gramas1 = document.getElementById('gramas1')
var resultado = document.getElementById('resultado')
function pesquisar() {
calculadoracalorias.style.display ='block'
}
function calcular(){
var valor = gramas2.value*cal1.value
var valorcal = valor/gramas1.value
cal2.value = valorcal
resultado.innerHTML = `${gramas2.value} gramas de ${alimento.value} é igual a ${valorcal} calorias.`
}
</script>
</body>
</html>