Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. </head>
  8. <body>
  9. <h2>JavaScript Celcius to Fahrenhet</h2>
  10. <p>Insert a number into one of the input fields below:</p>
  11.  
  12. <script>
  13. function convert()
  14. { var c ;
  15. c = (document.getElementById('cel1').value * 9/5) + 32;
  16. document.getElementById('fah1').value=Math.round(c);
  17. }
  18.  
  19. function convert1()
  20. {
  21. var f;
  22. f=(document.getElementById('fah1').value - 32)*5/9;
  23. document.getElementById('cel1').value=Math.round(f);
  24. }
  25.  
  26. </script>
  27. <form name='myform' method='post'>
  28. <table>
  29. <tr><td>celsius:</td><td><input type='text' id='cel1' onkeyup='convert()'/></td></tr>
  30. <tr><td>Fahrenheit:</td><td><input type='text' id='fah1' onkeyup='convert1()'/></td></tr>
  31. </table>
  32. </form>
  33.  
  34.  
  35. </body>
  36. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement