Skip to content

Commit 2dc50cb

Browse files
authored
farenheit Conversion JavaScript application
1 parent 9ee1dfc commit 2dc50cb

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

farenheit.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<html>
2+
<head>
3+
<script>
4+
5+
//find celsius from fahrenheit javascript function
6+
//by tutorialsmade.com
7+
8+
function findCelsius(){
9+
var fahrenheit = document.getElementById("Fahrenheit").value;
10+
var celsius;
11+
if(fahrenheit != ''){
12+
celsius = (fahrenheit - 32) * 5/9;
13+
document.getElementById("output").innerHTML = celsius;
14+
}else{
15+
document.getElementById("output").innerHTML = "Please enter a value!";
16+
}
17+
}
18+
19+
//this is just to make sure if the user enter number or not, not actually needed for this program
20+
//this function will allow only numbers to be entered in the textbox
21+
function allowOnlyNumbers(evt) {
22+
evt = (evt) ? evt : window.event;
23+
var charCode = (evt.which) ? evt.which : evt.keyCode;
24+
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
25+
return false;
26+
}
27+
return true;
28+
}
29+
30+
</script>
31+
</head>
32+
<body>
33+
<h2>Enter Fahrenheit</h2>
34+
<input type="text" id="Fahrenheit" onkeypress="return allowOnlyNumbers()" />
35+
<strong>Fahrenheit</strong>
36+
37+
<h4>Output: <span id="output"></span></h4>
38+
</body>
39+
</html>

0 commit comments

Comments
 (0)