Advertisement
Shailrshah

Real time Celsius to Fahrenheit Conversion

Feb 18th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <script>
  5.         function convert(unit){
  6.         if (unit == "C")
  7.             document.getElementById("f").value = document.getElementById("c").value * 1.8 + 32;
  8.         else
  9.             document.getElementById("c").value = (document.getElementById("f").value - 32) * 1.8;
  10.         }
  11.     </script>
  12. </head>
  13. <body>
  14. Celsius:<input id = "c" onkeyup = "convert('C')">
  15. Fahrenheit:<input id = "f" onkeyup="convert('F')">
  16. </form>
  17. </body>
  18. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement