No.101, Sec.2, Kuang-Fu Rd., HsinChu City, Taiwan 新竹市光復路二段101號
+886-571-5131#35162
klou@mx.nthu.edu.tw

C to F to C

Lab of AR/VR/XR & Machine Learning

C to F to C

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Functions</h1>

<p>This example calls a function which performs a calculation, and returns the result:</p>
<input type=input id="p1">
<input type=button onclick="myFunction()" value="C to F">
<input type=button onclick="yourFunction()" value="F to C">
<p id="demo"></p>
<script>
function myFunction() {
    var p1= document.getElementById("p1").value;
    document.getElementById("demo").innerHTML = p1*1.8+32;
}
function yourFunction() {
    var p1= document.getElementById("p1").value;
    document.getElementById("demo").innerHTML = (p1-32)*5/9;
}

</script>

</body>
</html>