repl.it
@austinsanims/

fahrenheitcelsiusconverter

HTML, CSS, JS

bruh

fork
loading
Files
  • index.html
  • script.js
  • style.css
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>repl.it</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <h1>Temperature Converter</h1>
    <h2><i>"Because Mrs. Reed won't check her spam box"&trade;</i></h2>
    <script src="script.js"></script>
    <form>
      Input: <input type="number" id="temperature" value="0"><br>
      Temperature:<br>
      <select id="temperaturetype">
        <option value="fah">Fahrenheit</option>
        <option value="cel">Celsius</option>
      </select><br>
      <input type="button" onclick="convert();"value="Submit">
      <p>The converted temperature is:</p>
      <p id="temperatureView"></p>
    </form>
  </body>
  <script>
    function convert() {
      var temperaturevar = document.getElementById("temperature").value;
      var temperaturetypevar = document.getElementById("temperaturetype").value;
      if(temperaturetypevar === "fah") {
        var temperatureconverted = (temperaturevar - 32)*5/9
        document.getElementById("temperatureView").innerHTML = temperatureconverted;
      }
      else {
        var temperatureconverted = (temperaturevar * 9 / 5)+ 32
        document.getElementById("temperatureView").innerHTML = temperatureconverted;
      }
    }
  </script>
</html>
result
console