<html>
<head>
<title>Convert the Temperature</title>
<script type="text/javascript">
//This Code was created by David A. and Matt I. on July 28, 2008
//You may use this code freely
//you may edit thos code however you wish
//however please leave in who it was created by and the time
//this would be apprciated.
//Enjoy!
var theAlert = "Please enter a valid number ";
var fahren;
var convert;
var cent;
function convertToCent_onchange()
{
if(isNaN(document.form1.fahren.value) == true || document.form1.fahren.value == "")
{
alert(theAlert + "in the fahrenheit box");
document.form1.fahren.value = 32;
}
var fahren = document.form1.fahren.value;
var convert = 5/9 * (fahren - 32);
document.form1.cent.value = convert;
}
function convertToFahren_onchange()
{
if(isNaN(document.form1.cent.value) == true || document.form1.cent.value == "")
{
alert(theAlert + "in the celsius box");
document.form1.cent.value = 0;
}
var cent = document.form1.cent.value
var convert = (9/5 * cent) + 32;
document.form1.fahren.value = convert;
}
</script>
</head>
<body>
<h2>Convert the temperature</h2>
<form name="form1">
<table style="width: 306px;"><tr><td>
<p>Celcius</p></td><td>Fahrenheit</td></tr>
<tr><td>
<input type="text" name="cent" value="0" onchange="convertToFahren_onchange()" bgcolor="red">
</td><td>
<input type="text" name="fahren" value="32" onchange="convertToCent_onchange()">
</td></tr>
<tr><td colspan="2" style="text-align: center;">
<input type="button" value="Convert" name="convert">
</td></tr></table>
</form>
</body>
</html>