Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <title>Fahrenheit to Celcius Temperature Converter</title>
  7. </head>
  8. <script type="text/javascript">
  9. function temperatureConverter(valNum)
  10. {
  11. valNum = parseFloat(valNum);
  12. document.getElementById("outputCelcius").innerHTML=(valNum-32)/1.8;
  13. }
  14.  
  15. function temperatureConverter(valNum)
  16. {
  17. valNum = parseFloat(valNum);
  18. document.getElementById("outputFahrenheit").innerHTML=(valNum*1.8)+32;
  19. }
  20. </script>
  21. <body>
  22.  
  23. <h1>Temperature Converter</h1>
  24. <p>Type a value in the Fahrenheit field to convert the value to Celcius:</p>
  25.  
  26. <p>
  27. <label>Fahrenheit</label>
  28. <input id="temp" type="number" placeholder="Fahrenheit" oninput="temperatureConverter(this.value)" onchange="temperatureConverter(this.value)">
  29. </p>
  30. <p>Celcius: <span id="outputCelcius"></span></p>
  31. <p>Type a value in the Celsius field to convert the value to Fahrenheit:</p>
  32.  
  33. <p>
  34. <label>Celsius</label>
  35. <input id="inputCelsius" type="number" placeholder="Celsius" oninput="temperatureConverter(this.value)" onchange="temperatureConverter(this.value)">
  36. </p>
  37. <p>Fahrenheit: <span id="outputFahrenheit"></span></p>
  38.  
  39. <input type="button" id=ctof value="Convert to Fahrenheit"> <input type="button" id=ctof2 value="Convert to Celsius">
  40.  
  41. </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement