I need some help with the javascript code. I have the structure down I need help with the functions. I want to enter the temp in the box and the run the function and replace the number with the converted temperature. Can anyone help me. Here is where I'm at so far. Its almost all done just need help with the end. Here is my code.
<?xml version= "1.0: encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- homework 9.19 -->
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title> Fahrenheit and Celsius Converter </title>
<script type = "text/javascript">
//make convertC function
function convertC()
{
//get the number form field
var field1 = document.getElementById("Celsius");
var temp1 = parseFloat(field1.value);
var answer1 = 0;
answer1 = (5.0/9.0) * (temp1 - 32);
return answer1;
}
//make converF funtion
function convertF()
{
var field2 = document.getElementById("Fahrenheit");
var temp2 = parseFloat(field2.value);
var answer2 = 0;
answer2 = (9.0/5.0) * (temp2 + 32);
return answer2;
}
</script>
</head>
<body>
<h1> Fahrenheit and Celsius Converter </h1>
<table border = "1" width = "35%"
<thead>
<tr>
<td>Fahrenheit</td>
<td><input Celsius = "Celsius" type = "text" size = "25" /></td>
<td><input type = "button" value = "Convert to Celsius"
onclick = "convertC()" </td>
</tr>
<tr>
<td>Celsius</td>
<td><input Fahrenheit = "Fahrenheit" type = "text" size = "25" /></td>
<td><input type = "button" value = "Convert to Fahrenheit"
onclick = "convertF()"</td>
</tr>
</table>
</body>
</html>