Skip to content

Instantly share code, notes, and snippets.

@IanMcT
Created February 24, 2017 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanMcT/4fe7699ce330605f53537b6227473bd7 to your computer and use it in GitHub Desktop.
Save IanMcT/4fe7699ce330605f53537b6227473bd7 to your computer and use it in GitHub Desktop.
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