-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculadora.html
130 lines (108 loc) · 3.93 KB
/
calculadora.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculadora de Ração para Pets</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
min-height: 100vh;
background-image: url(img/51183.jpg);
background-size: cover;
background-position: center;
}
.container {
width: 420px;
background: transparent;
border: 2px solid rgba(25, 27, 146, 0.664);
backdrop-filter: blur(20px);
box-shadow: 0 0 10px rgba(0, 0, 0, .2);
color: #000000;
border-radius: 10px;
padding: 30px 40px;
}
h1 {
text-align: center;
color: #333;
}
form {
display: flex;
flex-direction: column;
margin-top: 20px;
}
label {
margin-bottom: 5px;
color: #000000;
}
input,
select {
padding: 10px;
margin-bottom: 20px;
border: 1px solid #000000;
border-radius: 4px;
}
button {
padding: 10px 15px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #2165ad;
}
#resultado {
margin-top: 20px;
padding: 10px;
background-color: #f8f9fa;
border: 1px solid #fffdfd;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="input-field">
<div class="container">
<h1>Calculadora de Ração Planpet</h1>
<form id="petForm">
<label for="tipo_pet">Seu pet é cachorro ou gato?</label>
<select id="tipo_pet" name="tipo_pet" required>
<option value="">Selecione uma opção</option>
<option value="cachorro">Cachorro</option>
<option value="gato">Gato</option>
</select>
<label for="idade">Qual a idade do seu pet (em anos)?</label>
<input type="number" id="idade" name="idade" min="0" step="any" required>
<label for="peso">Qual o peso do seu pet (em kg)?</label>
<input type="number" id="peso" name="peso" min="0" step="any" required>
<button type="submit">Calcular</button>
</form>
<div id="resultado"></div>
</div>
<script>
function calcularRacao(tipoPet, idade, peso) {
if (tipoPet === 'cachorro') {
return idade < 1 ? peso * 40 : peso * 30;
} else if (tipoPet === 'gato') {
return idade < 1 ? peso * 50 : peso * 20;
} else {
return 0;
}
}
document.getElementById('petForm').onsubmit = function (event) {
event.preventDefault();
var tipoPet = document.getElementById('tipo_pet').value.toLowerCase();
var idade = parseFloat(document.getElementById('idade').value);
var peso = parseFloat(document.getElementById('peso').value);
var quantidadeRacao = calcularRacao(tipoPet, idade, peso);
document.getElementById('resultado').innerText = 'Você deve dar aproximadamente ' + quantidadeRacao.toFixed(0) + 'g de ração por dia para o seu ' + tipoPet + '.';
}
</script>
</body>
</html>