Temperature Conversion

Fahrenheit Celsius

Is equal to:

<SCRIPT>

function displayTemp(form) {
     var tempVal, finalC, finalF, finalTemp;

     // checks to see if the first TC radio button is checked
     // - meaning convert Fahrenheit to Celsius

     if (form.TC[0].checked) {
          // get the inputted value from yourInput text field
          tempVal = form.yourInput.value;
          // formula for converting from Fahrenheit to Celsius
          finalC = (tempVal - 32) * (5 / 9);
          finalTemp = Math.
round(finalC) + " degrees Celsius";
     }
     // checks to see if the second TC radio button is checked
     // - meaning convert Celsius to Fahrenheit

     else {
          // get the inputted value from yourInput text field
          tempVal = form.yourInput.value;
          // formula for converting Celsius from to Fahrenheit
          finalF = (tempVal * (9 / 5)) + 32;
          finalTemp =Math.
round(finalF) + " degrees Fahrenheit";
     }
    // output the result of the conversion to the result text field
    form.result.value = finalTemp;
}

</SCRIPT>

<FORM>
     <INPUT TYPE="text" NAME="yourInput
" onChange="displayTemp(this.form);">

the radio buttons act as an array in this case, with the first radio button being checked,
an array, in this case, means that when you check one of the buttons the other one automatically gets unchecked

     <INPUT TYPE="radio" NAME="TC" onClick="displayTemp(this.form);" CHECKED> Fahrenheit
    
<INPUT TYPE="radio" NAME="
TC" onClick="displayTemp(this.form);"> Celsius
     Is equal to:
     <INPUT TYPE="text" NAME="result
">
</FORM>