-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
91 lines (78 loc) · 2.93 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
88
89
90
91
<!DOCTYPE html>
<html>
<link href="./index.css" rel="stylesheet" type="text/css">
<title>Temperature Converter</title>
<body>
<div>
<div id="a">
<h1>Temperature Converter...</h1>
<input type="text" placeholder=" Enter the Temperature" name="temp" id="input" required></br></br>
<input type="radio" value="Celsius" name="unit">Celsius
<input type="radio" value="Farhenheit" name="unit">Farhenheit
<input type="radio" value="Kelvin" name="unit">Kelvin
<h1> Convert to </h1></br>
<input type="radio" value="CCelsius" name="cunit">Celsius
<input type="radio" value="FFarhenheit" name="cunit">Farhenheit
<input type="radio" value="KKelvin" name="cunit">Kelvin</br></br>
<input type="button" value="Convert" onclick="Convert()" id="convert">
<div id="result1">
<h1>Result:</h1>
<input type="text" id="result" value="0" readonly>
</div>
<footer>
<div id="footer">
<p>Developed by:- Mohammed Kaifulla Kazim</p>
<p>For any queries mail to:- kaifullakazim@gmail.com</p>
<p>To get the Source Code of this Project <a href="https://github.com/KaifullaKazim/Temperature_Converter" target="_blank">Click Here</a></p>
</div>
</footer>
</div>
</div>
</body>
</html>
<script>
function Convert()
{
let x= document.querySelector("#input").value;
let y= document.querySelector('input[name="unit"]:checked').value;
let z= document.querySelector('input[name="cunit"]:checked').value;
let result;
if(y=="Celsius" && z=="CCelsius"){
x=parseFloat(x);
result=x;
}
else if(y=="Celsius" && z=="FFarhenheit"){
x=parseFloat(x);
result=(x*9/5)+32;
}
else if(y=="Celsius" && z=="KKelvin"){
x=parseFloat(x);
result=parseInt(x)+273.15;
}
else if(y=="Farhenheit" && z=="CCelsius"){
x=parseFloat(x);
result=(x-32)*5/9;
}
else if(y=="Farhenheit" && z=="FFarhenheit"){
x=parseFloat(x);
result=x;
}
else if(y=="Farhenheit" && z=="KKelvin"){
x=parseFloat(x);
result=(x-32)*5/9+273.15;
}
else if(y=="Kelvin" && z=="CCelsius"){
x=parseFloat(x);
result=x-273.15;
}
else if(y=="Kelvin" && z=="FFarhenheit"){
x=parseFloat(x);
result=(x-273.15)*9/5+32;
}
else if(y=="Kelvin" && z=="KKelvin"){
x=parseFloat(x);
result=x;
}
document.querySelector("#result").value=result;
}
</script>