- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfarenheit.html
More file actions
Latest commit
39 lines (34 loc) · 1.11 KB
/
Copy pathfarenheit.html
File metadata and controls
39 lines (34 loc) · 1.11 KB
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
<html>
<head>
<script>
//find celsius from fahrenheit javascript function
//by tutorialsmade.com
functionfindCelsius(){
varfahrenheit=document.getElementById("Fahrenheit").value;
varcelsius;
if(fahrenheit!=''){
celsius=(fahrenheit-32)*5/9;
document.getElementById("output").innerHTML=celsius;
}else{
document.getElementById("output").innerHTML="Please enter a value!";
}
}
//this is just to make sure if the user enter number or not, not actually needed for this program
//this function will allow only numbers to be entered in the textbox
functionallowOnlyNumbers(evt){
evt=(evt) ? evt : window.event;
varcharCode=(evt.which) ? evt.which : evt.keyCode;
if(charCode>31&&(charCode<48||charCode>57)){
returnfalse;
}
returntrue;
}
</script>
</head>
<body>
<h2>Enter Fahrenheit</h2>
<inputtype="text" id="Fahrenheit" onkeypress="return allowOnlyNumbers()" />
<strong>Fahrenheit</strong>
<h4>Output: <spanid="output"></span></h4>
</body>
</html>