-
Notifications
You must be signed in to change notification settings - Fork 0
/
forms-element-output.html
61 lines (60 loc) · 2 KB
/
forms-element-output.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
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="cev-02.ico" type="image/x-icon">
<title>Formulário</title>
<style>
* {
font-family: Arial, Helvetica, sans-serif;
}
fieldset {
background-color: bisque;
width: 300px;
}
</style>
</head>
<body>
<h1>Elemento Output em Formulário</h1>
<fieldset>
<form action="cadastro.php" method="get" autocomplete="on">
<p>
<label for="in1">Número 1:</label>
<input type="number" name="n1" id="in1" min="0" max="50" required oninput="isoma.innerHTML = Number(in1.value) + Number(in2.value)">
</p>
<p>
<label for="in2">Número 2:</label>
<input type="number" name="n2" id="in2" min="0" max="50" required oninput="isoma.innerHTML = Number(in1.value) + Number(in2.value)">
</p>
<label for="isoma">Soma:</label>
<output name="soma" id="isoma">0</output>
<hr>
<p>
<label for="inum">Número: </label>
<input type="range" name="num" id="inum" min="0" max="10" value="5" oninput="ival.innerHTML = Number(inum.value)">
<output id="ival">5</output>
</p>
<hr>
<p>
<label for="iano">Em que ano você nasceu?</label>
<input type="number" name="ano" id="iano" min="1900" max="2024" oninput="calcIdade()">
</p>
<p>
<label for="iidade">Sua idade é:</label>
<output id="iidade">0</output>
</p>
</fieldset>
<p>
<input type="submit" value="Enviar">
<input type="reset" value="Limpar">
</p>
</form>
<script>
function calcIdade() {
let atual = new Date().getFullYear()
iidade.innerHTML = Number(atual) - Number(iano.value)
}
</script>
</body>
</html>