Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Konverteraren</title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="style.css">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- </head>
- <body>
- <div id="content">
- <div id="feature">
- <h2>The converte r</h2>
- <p>Denna konverterare är nödvändig för dig som skall
- byta</p>
- </div>
- <div id="data">
- <div class="first">
- <p>Celsius - Fahrenheit</p>
- <p><input id="c" onkeyup="convert('C')"> C</p>
- <p><input id="f" onkeyup="convert('F')"> F</p>
- </div>
- <div class="second">
- <p>Km/h - Mp/h</p>
- <p><input id="kmh" onkeyup="converter2('KMH')"> Km/h</p>
- <p><input id="mph" onkeyup="converter2('MPH')"> Mp/h</p>
- </div>
- <div class="third">
- <p>Inches - cm</p>
- <p><input id="inches" onkeyup="converter3('INCHES')"> In</p>
- <p><input id="cm" onkeyup="converter3('CM')"> Cm</p>
- </div>
- <div id="footer">
- <p>Copyright 2017 - Pontus Wilhelm Tell</p>
- </div>
- </div>
- </div>
- <!--Scriptet fungerar som det ska, har nu lagt till så att decimalproblemeet
- inte längre finns. Nu blir det två decimaler på degree och measure (hastighet ansåg jag inte
- skulle ha avrundning till 2 decimaler)-->
- <script>
- function convert(degree) {
- var x;
- if (degree == "C") {
- x = document.getElementById("c").value * 9 / 5 + 32;
- document.getElementById("f").value = Math.round(x*100)/100;
- } else {
- x = (document.getElementById("f").value -32) * 5 / 9;
- document.getElementById("c").value = Math.round(x*100)/100;
- }
- }
- function converter2(speed){
- var y;
- if (speed == "KMH"){
- y = document.getElementById("kmh").value / 1.609344;
- document.getElementById("mph").value = Math.round(y);
- }else{
- y = document.getElementById("mph").value * 1.609344;
- document.getElementById("kmh").value = Math.round(y);
- }
- }
- function converter3(measure){
- var z;
- if (measure == "INCHES"){
- z = document.getElementById("inches").value * 2.540;
- document.getElementById("cm").value = Math.round(z*100)/100;
- }else{
- z = document.getElementById("cm").value / 2.540;
- document.getElementById("inches").value = Math.round(z*100)/100;
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement