File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments