Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Konverteraren</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <link rel="stylesheet" href="style.css">
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. </head>
  10. <body>
  11. <div id="content">
  12.  
  13. <div id="feature">
  14. <h2>The converte r</h2>
  15. <p>Denna konverterare är nödvändig för dig som skall
  16. byta</p>
  17. </div>
  18.  
  19. <div id="data">
  20. <div class="first">
  21. <p>Celsius - Fahrenheit</p>
  22. <p><input id="c" onkeyup="convert('C')"> C</p>
  23. <p><input id="f" onkeyup="convert('F')"> F</p>
  24. </div>
  25.  
  26. <div class="second">
  27. <p>Km/h - Mp/h</p>
  28. <p><input id="kmh" onkeyup="converter2('KMH')"> Km/h</p>
  29. <p><input id="mph" onkeyup="converter2('MPH')"> Mp/h</p>
  30. </div>
  31.  
  32. <div class="third">
  33. <p>Inches - cm</p>
  34. <p><input id="inches" onkeyup="converter3('INCHES')"> In</p>
  35. <p><input id="cm" onkeyup="converter3('CM')"> Cm</p>
  36. </div>
  37.  
  38. <div id="footer">
  39. <p>Copyright 2017 - Pontus Wilhelm Tell</p>
  40. </div>
  41.  
  42. </div>
  43. </div>
  44. <!--Scriptet fungerar som det ska, har nu lagt till så att decimalproblemeet
  45. inte längre finns. Nu blir det två decimaler på degree och measure (hastighet ansåg jag inte
  46. skulle ha avrundning till 2 decimaler)-->
  47. <script>
  48. function convert(degree) {
  49. var x;
  50. if (degree == "C") {
  51. x = document.getElementById("c").value * 9 / 5 + 32;
  52. document.getElementById("f").value = Math.round(x*100)/100;
  53. } else {
  54. x = (document.getElementById("f").value -32) * 5 / 9;
  55. document.getElementById("c").value = Math.round(x*100)/100;
  56. }
  57. }
  58. function converter2(speed){
  59. var y;
  60. if (speed == "KMH"){
  61. y = document.getElementById("kmh").value / 1.609344;
  62. document.getElementById("mph").value = Math.round(y);
  63. }else{
  64. y = document.getElementById("mph").value * 1.609344;
  65. document.getElementById("kmh").value = Math.round(y);
  66. }
  67. }
  68. function converter3(measure){
  69. var z;
  70. if (measure == "INCHES"){
  71. z = document.getElementById("inches").value * 2.540;
  72. document.getElementById("cm").value = Math.round(z*100)/100;
  73. }else{
  74. z = document.getElementById("cm").value / 2.540;
  75. document.getElementById("inches").value = Math.round(z*100)/100;
  76. }
  77. }
  78. </script>
  79. </body>
  80. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement