-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
87 lines (76 loc) · 2.01 KB
/
index.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
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8" />
<style>
form{
border: 5px double green;
background-color: #B9D8B1;
padding: 4px;
text-align:left;
left:37%;
top:29%;
width:270px;
height:270px;
}
label{
margin-top: 8px;
}
input{
margin-top: 8px;
background-color: #BDC39D
}
</style>
<title> Conversor de Escalas Termométricas </title>
</head>
<body>
<form name="convert">
<div>
<h3><a name="titulo"></a><img src="temp.png" height="30" width= auto>Conversor de Temperatura</h1>
</div>
<div>
<label>Fahrenheit:</label>
<input type="text" name="tempfahrenheit" size="7" onchange="conversao('fah')">
</div>
<div>
<label>Celsius:</label>
<input type="text" name="tempcelsius" size="7" onchange="conversao('cel')">
</div>
<div>
<label>Kelvin:</label>
<input type="text" name="tempkelvin" size="7" onchange="conversao('kel')">
</div>
<br /><br />
<input type="button" value="limpar" onclick="clearAll();">
</form>
<script type="text/javascript">
function conversao(temp)
{
var fahrenheit = document.convert.tempfahrenheit;
var celsius = document.convert.tempcelsius;
var kelvin = document.convert.tempkelvin;
if (temp == "fah")
{
celsius.value = Math.round((fahrenheit.value - 32) * (5/9));
kelvin.value = Math.round((parseInt(celsius.value) + 459.67) * (5/9));
}
else if (temp == "kel")
{
fahrenheit.value = Math.round((parseInt(celsius.value) * (9/5)) - 459.67);
celsius.value = Math.round((fahrenheit.value - 32) * (5/9));
}
else
{
fahrenheit.value = Math.round((parseInt(celsius.value) * (9/5)) + 32);
kelvin.value = Math.round((parseInt(celsius.value) + 273));
}
}
function clearAll()
{
document.convert.tempfahrenheit.value="";
document.convert.tempcelsius.value="";
document.convert.tempkelvin.value="";
}
</script>
</body>
</html>