-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
87 lines (69 loc) · 2.85 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>
<head>
<link rel="stylesheet" href="Index.css" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name='author' content="Vencholin">
</head>
<body>
<div id=Cambio-de-Temperatura>
<h3>Cambio de unidades de temperatura</h3>
<input type="text" id="C" size="18" value="0" onchange="Cfunc()" />
<label id="C" for="C"> C </label>
</br>
<input type="text" id="K" size="18" value="0" onchange="Kfunc()" />
<label id="K" for="K"> K </label>
</br>
<input type="text" id="F" size="18" value="0" onchange="Ffunc()" />
<label id="F" for="F"> F </label>
</div>
</div>
<script> var C, K, F;
function init()
{
C = document.getElementById("C");
K = document.getElementById("K");
F = document.getElementById("F");
}
function Cfunc()
{
document.getElementById('C').style.color = 'red'
document.getElementById('K').style.color = 'black'
document.getElementById('F').style.color = 'black'
K.value = (parseFloat(C.value) + 273).toFixed(2);
F.value = (parseFloat(C.value) * 1.8 + 32).toFixed(2);
if (isNaN(document.getElementById("K").value)){
K.value = 'No ha insertado un número'
F.value = 'No ha insertado un número'
alert('Este programa NO admite letras')
}
}
function Ffunc()
{ document.getElementById('F').style.color = 'red'
document.getElementById('K').style.color = 'black'
document.getElementById('C').style.color = 'black'
C.value = ((parseFloat(F.value) - 32) * 5/9).toFixed(2) ;
K.value = ((parseFloat(F.value)-32) * 5/9 + 273).toFixed(2);
if (isNaN(document.getElementById("K").value)){
K.value = 'No ha insertado un número'
C.value = 'No ha insertado un número'
alert('Este programa NO admite letras')
}
}
function Kfunc()
{
document.getElementById('K').style.color = 'red'
document.getElementById('F').style.color = 'black'
document.getElementById('C').style.color = 'black'
C.value = (parseFloat(K.value) - 273).toFixed(2);
F.value = ((parseFloat(K.value) - 273) * 1.8 + 32).toFixed(2);
if (isNaN(document.getElementById("F").value)){
F.value = 'No ha insertado un número'
C.value = 'No ha insertado un número'
alert('Este programa NO admite letras')
}
}
init();
</script>
</body>
</html>