John B.

asked • 10/08/14

how would i write a javascript code for a temperature convert?

heres the HTML file:
<!DOCTYPE html>
<html>
<head>
<title>Temperature Converter</title>
<script type="text/javascript" src="Week7.js"></script>
</head>
<body>
<p>Enter a Temperature to Convert in the field below and select the starting scale.</p>
<input type="text" name="txtTemp" id="txtTemp" placeholder="Enter a Temperature" />
<br />
<br />
<input type="radio" id="radFahrenheit" name="radTemp" checked/>Fahrenheit to Celcius
<br/>
<br/>
<input type="radio" id="radCelcius" name="radTemp"/>Celcius to Fahrenheit
<br/>
<br/>
<br/>
<br/>
<button onclick="ConvertTemp();">Convert</button>
<br/>
<br/>

<div id="divResults"></div>
</body>
</html>
 
Im probably way off on my code but ehh I'm just now learning so with time will come experience and other good things:
 
function ConvertTemp(){
var radFahrenheit = document.getElementById('radFahrenheit');
var radCelcius = document.getElementById('radCelcius');
var txtTemp = document.getElementById('txtTemp');
var divResults = document.getElementById('divResults');

if(radF.checked){
{
radFahrenheit = (radCelcius * (9/5)) + 32;
divResults = radFahrenheit;
FahrenheitToCelcius();
}else if(radC.checked){
radCelcius = (radFahrenheit -32) * (5 / 9);
divResults = radCelcius;
CelciustoFahrenheit();
}
}
 
I really wish I could talk to my teacher to get guidance from him but it's fall break and this assignment is do before classes start back so I am hoping that you kind people can give me some guidance. Thank you also I know you don't have to help me at all but I really do appreciate those of you who will help me.

1 Expert Answer

By:

Baljeet S. answered • 10/31/14

Tutor
New to Wyzant

Professional Programmer/PHP/Mysql/HTML/Oracle Service Cloud

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.