Thanks for viewing. To be perfectly honest, this is (in part) for school. the project is to write a script to prompt for a temperature in Fahrenheit and output the Celsius equivilant.
I'm ahead in my school work, and so decided to take my time and have some fun with this. Here is my code:
<html>
<head> <title>Temperature Converter</title> </head>
<body>
<br>
<center><h2>Temperature Conversion</h2></center>
<br><br>
<script type = "text/javascript">
function f2c()
{
var f=prompt("What Temperature?"," ");
if (f!=null && f!=" ")
{
var c= (5/9)*(f-32)
document.write (f + " Fahrenhiet is equal to " + c + " Celsius.");
}
}
function c2f()
{
var c=prompt("What Temperature?"," ");
if (c!=null && c!=" ")
{
var f= ((9/5)*c)+32
document.write (c + " Celsius is equal to " + f + " Fahrenheit.");
}
}
</script>
<center><input type="button" onclick="f2c()" value="Fahrenheit to Celsius"/></center>
<center><input type="button" onclick="c2f()" value="Celsius to Fahrenheit"/></center>
</body>
</html>
I have some c++ and logo experience, and understand programming structure, butHTML is a bit new to me. WhenI run this file as HTML it all works great, but what I would like to do next is: After you get your results displayed, have a link or button you can click to "start over", bring you back to the start page without having to hit 'back' on your browser.
I will provide a link to the site this lab is posted on for anybody who would like to confirm what I said in the beginning.
Thanks