var convertCtoF = document.getElementById("degC");
convertCtoF.onchange = function(){ //onchange means that every time the value in the input box changes, this function will run
var degreesC = document.getElementById("degC").value; // this is the value from the form field
var degC = (degreesF-32) * (5/9);
document.getElementById("degC").value=degC;
// your calculations go here. You'll start with the variable degreesC, convert it to Fahrenheit
// and place the result in the variable 'degreesF'
var degreesF = (degC * 9/5 + 32);
return degreesF;// you will set this to the results of your conversion
// now we write the result to the page
document.getElementById("degFOut").innerHTML = degreesF;
}
var convertFtoC = document.getElementById("degF");
convertFtoC.onchange = function(){ //onchange means that every time the value in the input box changes, this function will run
var degreesF = document.getElementById("degF").value; // this is the value from the form field
var degF = degC= 5/9*(degF-32);
document.getElementById("degF").value=degF;
// your calculations go here. You'll start with the variable degreesF, convert it to Celsius
// and place the result in the variable 'degreesC'
var degreesC = (degreesF- 32) * (5/9);
return degreesC;// you will set this to the results of your conversion
// now we write the result to the page
document.getElementById("degCOut").innerHTML = degreesC;
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.