Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html lang="pl">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Stacja Meteo</title>
  6. </head>
  7. <body>
  8. <div id="form1">
  9. <h2>Zamiana jednostek temperatury w <sup>o</sup>C<br></h2>
  10. <form name="form1">
  11. <label for="liczba">
  12. <input type="text" id="liczba"/><br>
  13. <br> </label>
  14. Zamień na <br>
  15. <input type="button"
  16. onclick="kelwiny();" value="Kelwiny"/>
  17. <input type="button"
  18. onclick="far();"
  19. value="Farenheit"/>
  20. </form>
  21. <div id="wynik">TU WYNIK</div><br/>
  22. <script type="text/javascript">
  23. function kelwiny()
  24. {
  25. var x = document.getElementById("liczba").value;
  26. if(x=='' || isNaN(x))
  27. {
  28. alert("Należy wpisać wartość liczbową");
  29. }
  30. else
  31. {
  32. x=parseFloat(x);
  33. var wynik=x+273.15;
  34. document.getElementById("wynik").innerHTML = wynik+"K";
  35. }
  36. }
  37. function farenheity()
  38. {
  39. var x = document.getElementById("liczba").value;
  40. if(x=="" || isNaN(x))
  41. {
  42. alert("Należy wpisać wartość liczbową");
  43. }
  44. else
  45. {
  46. x=parseFloat(x);
  47. var wynik=1.8*x+32;
  48. document.getElementById("wynik").innerHTML = wynik+"F";
  49. }
  50. }
  51. </script>
  52. </div>
  53.  
  54. </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement