Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72388

Issues with temperature converter javascript [duplicate]

$
0
0

I'm a beginner of programming and trying to make a temperature converter of C2F and F2C with Javascript but it doesn't work. My goal is that when user enter a number, cliking on C2F button will get the result of Fahrenheit, and F2C button will show the result of Celcius. However somehow when I enter the number, no results show up.

<!DOCTYPE html><html><head><title>Temperature Converter</title><script type="text/javascript">
	function CelFahr(){
		var cel = document.getElementById("tempinput").value;
		var fahr = (cel * 9 / 5) + 32;
		document.getElementById("tempoutput").innerHTML = fahr; 
	}

	function FahrCel(){
		var fahr = document.getElementById("tempinput").value;
		var cel = (fahr - 32) * 5/9;
		document.getElementById("tempoutput").innerHTML = cel;
	}</script></head><body bgcolor="#4092C9" align="center"><h1 align="Center">Temperature Converter</h1><label for="tempinput">Enter the temperature.</label><br><br><input type="text" id="tempinput" Placeholder=Enter><br><br><input type="text" id="tempoutput" Placeholder=Result><br><br><br><br><button onclick="CelFahr()" id="c2f">Celcius to Fahrenheit</button><button onclick="FahrCel()" id="f2c">Fahrenheit to Celcius</button><input value="Reset" type="Reset" id="Reset"/></body></html>

Viewing all articles
Browse latest Browse all 72388

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>