Javascript Temperature Conversations

Temperature Conversations using HTML5 and Javascript

This useful code can convert input from Fahrenheit to Celsius and Kelvin as well as input from Celsius to Fahrenheit to Kelvin.

HTML with Javascript

<!DOCTYPE html>
        <title>Temperature Conversions</title>
        <body bgcolor="#eeffa0">
        <font color="green"; align="center">
    <p style=" font-size:30px";>Temperature Converter</p>
        Enter Fahrenheit Temperature here: <input type="text" id="txt1" name="text1"><br>
        <p id="C"></p> 
        <button onclick="myFunction()">Temperature in Celsius</button> <br>
          <p id="m"></p> 
        <button onclick="myFunction4()">Temperature in Kelvin</button> <br><br>
        Enter Celsius Temperature here: <input type="text" id="txt2" name="text2"><br>
         <p id="F"></p>
        <button onclick="myFunction2()">Temperature in Fahrenheit</button> 
           <p id="K"></p> 
        <button onclick="myFunction3()">Temperature in Kelvin</button> 
            function myFunction() { 
        var y = document.getElementById("txt1").value; 
        var y = 5/9 *(y-32);
        document.getElementById("C").innerHTML = y; }
        function myFunction3() { 
        var c = document.getElementById("txt2").value; 
        var c = +c + 273.15

document.getElementById("K").innerHTML = c; }
        function myFunction2() { 
        var z = document.getElementById("txt2").value; 

        var z = (9/5)*z + 32;
         document.getElementById("F").innerHTML = z;}
         function myFunction4() { 
        var m = document.getElementById("txt1").value; 
        var m= (m-32) * 5/9 + 273.15

document.getElementById("m").innerHTML = m; }

Click here to run this Code


Popular posts from this blog

HTML5 Crossword 1

Multi-tap Keypad Text Entry