Temperature converter with JavaScript This is one of my first simple javascript projects. Feedback is appreciated! Basically, everytime the select option is changed, the result is shown.



&lt;!DOCTYPE html&gt;
 &lt;html lang="en"&gt;
 &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;Document&lt;/title&gt;
  &lt;style&gt;
  &lt;/style&gt;
 &lt;/head&gt;
 &lt;body&gt;
  &lt;/select&gt;
  &lt;div id="sect"&gt;
   &lt;section&gt;
    &lt;select onchange="onChange('from'); calculate()" id="selectFrom"&gt;
     &lt;option value="Celcius"&gt;Celcius&lt;/option&gt;
     &lt;option value="Farenheit"&gt;Farenheit&lt;/option&gt;
     &lt;option value="Kelvin"&gt;Kelvin&lt;/option&gt;
    &lt;/select&gt;
    &lt;span class="toText"&gt;to&lt;/span&gt;
    &lt;select onchange="onChange('to'); calculate()" id="selectTo"&gt;
     &lt;option value="Celcius"&gt;Celcius&lt;/option&gt;
     &lt;option value="Farenheit"&gt;Farenheit&lt;/option&gt;
     &lt;option value="Kelvin"&gt;Kelvin&lt;/option&gt;
    &lt;/select&gt;
   &lt;/section&gt;
   &lt;section&gt;
    &lt;input type="text" id="from" onchange="calculate()"&gt; &lt;span 
id="toText"&gt; to &lt;/span&gt; &lt;input type="text" id="to"&gt;
   &lt;/section&gt;
   &lt;br&gt;

   &lt;section&gt;
    &lt;p id="results"&gt;&lt;/p&gt;
   &lt;/section&gt;
  &lt;/div&gt;
  &lt;script&gt;
   onChange('from');
   onChange('to');
   function onChange(fromOrTo) {
    if(fromOrTo === 'from') {
     document.getElementById("from").placeholder = document.getElementById("selectFrom").value;
    } else if(fromOrTo === 'to') {
     document.getElementById("to").placeholder = document.getElementById("selectTo").value;
    } 
   }
   function calculate() {
    var from = document.getElementById("selectFrom");
    var to = document.getElementById("selectTo");
    var fromValue = parseInt(document.getElementById("from").value);
    var toValue = parseInt(document.getElementById("to").value);
    if(from.value == "Celcius") {
     if(to.value == "Farenheit") {
      result = ((fromValue * 9)/5) + 32;
     }
     else if(to.value == "Kelvin") {
      result = fromValue + 273;
     } else {
      result = "Cannot calculate!";
     }
     document.getElementById("to").value = result.toFixed(2);
    }
    else if(from.value == "Farenheit") {
     if(to.value == "Celcius") {
      result = ((fromValue - 32) * 5)/9
     }
     else if(to.value == "Kelvin") {
      result = ((fromValue + 459.67) * 5)/9;
     } else {
      result = "Cannot calculate!";
     }
     document.getElementById("to").value = result.toFixed(2);
    }
    else if(from.value == "Kelvin") {
     if(to.value == "Celcius") {
      result = fromValue - 273;
     }
     else if(to.value == "Farenheit") {
      result = 1.8 * (fromValue-273) + 32;
     } else {
      result = "Cannot calculate!";
     }
     document.getElementById("to").value = result.toFixed(2);
    }
   }
  &lt;/script&gt;
 &lt;/body&gt;
 &lt;/html&gt;
Some minor observations:


It's a good idea to check your html projects with a validator of some sort (for example: https://validator.w3.org/). There are some slight mistakes in your file which can easily be caught by any validator.
Usually you want to keep content, presentation and behavior separated from another. This means you put scripts, CSS etc. into their own files instead of having them all in your html file.
From a usability perspective I think it would be nicer to have explicit control over when the conversion takes place. E.g. via a button or something similiar.