Skip to content

Instantly share code, notes, and snippets.

@IanMcT
Created Feb 24, 2017
Embed
What would you like to do?
Basis for Temp Converter - HMTL and JavaScript
<html>
<head>
</head>
<body>
<p>Temp: <br />
<input type="text" id="tempInput" /><br />
<input id="radioCT" type="radio" name="conversionType" value="CToF" checked>Celsius to Fahrenheit</input><br />
<input id="radioCT" type="radio" name="conversionType" value="FToC">Fahrenheit to Celsius</input><br />
<button onclick="convertTemp()">Convert</button>
</p>
<p id="output">&nbsp;</p>
<script>
function convertTemp()
{
alert("in function");
var t = document.getElementById("tempInput").value;
alert(t);
var convertCtoF = document.getElementById("radioCT").checked;
alert(convertCtoF);
if(convertCtoF){
document.getElementById("output").innerHTML = "convert c to f";
}else{
document.getElementById("output").innerHTML = "convert f to c";
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment