Начало
Эквиваленты
Температура 2
Другой способ использовать JavaScript, чтобы найти больше температурных эквивалентов.
Fahrenheit
Celsius
Is Equal to:
JavaScript Equivalents: Температура 2
<!-- TWO STEPS TO INSTALL TEMPERATURE EQUIVALENTS 2: 1. Put the designated code into the HEAD of your HTML document 2. Paste the last code into the BODY of your HTML document --> <!-- STEP ONE: Copy this code into the HEAD of your HTML document --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <! > <! > function displayTemp(){ if (document.forms[0].elements[1].checked){ var tempVal = document.forms[0].yourInput.value var finalC = (tempVal-32)*5/9 var finalTemp = Math.round(finalC) + " degrees Celcius" } if (document.forms[0].elements[2].checked){ var tempVal = document.forms[0].yourInput.value var finalF = (tempVal*9/5)+32 var finalTemp = Math.round(finalF) + " degrees Fahrenheit" } document.forms[1].result.value = finalTemp; } </script> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <CENTER> <FORM> <INPUT TYPE="text" name="yourInput" size=8 value="" onChange="displayTemp();"> <INPUT TYPE="radio" Name="F" Size=1 onclick="displayTemp();">Fahrenheit <INPUT TYPE="radio" Name="F" Size=1 onclick="displayTemp();">Celsius </FORM> <P> <FORM name=buttons> <Br> <Br> Is Equal to:<P> <INPUT TYPE="text" Name="result" Size=30 Value=""> </FORM> </CENTER> <!-- Script Size: 1.35 KB -->