Script Categories













Equivalents >>> Temperature 2.

Another way to use JavaScript to find temperature equivalents.

Fahrenheit Celsius


Is Equal to:

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
function displayTemp(){
if (document.Zero.elements[1].checked){
var tempVal = document.Zero.yourInput.value
var finalC = (tempVal-32)*5/9
var finalTemp = Math.round(finalC) + " degrees Celcius"
}
if (document.Zero.elements[2].checked){
var tempVal = document.Zero.yourInput.value
var finalF = (tempVal*9/5)+32
var finalTemp = Math.round(finalF) + " degrees Fahrenheit"
}
document.buttons.result.value = finalTemp;
}
</script>
<FORM name="Zero" id="Zero">
<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>
Is Equal to:
<INPUT TYPE="text" Name="result" Size=30 Value="">
</FORM>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©