Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Javascript/HTML Temperature converter

thebombdave
thebombdave 


Temperature Converter Create a file called tempconv.html Have a text box that you enter your temperature into Instead of a textbox to write the answer, use a div and getElementById and innerHTML Have a button that converts from C to F Have another button that converts from F to C Use 2 separate functions make sure ALL your javascript code is up in the head Set up an event for the button (Links to an external site.) to do the calculations The two functions needed are below: function convertToC(F) { var result = (temp -32) * (5/9); return result; } var c = convertToC(78); function convertToF(C) { var result = (temp * (9/5)) + 32; return result; } var f = convertToF(25); Attachments
Tags Clarifications

Answers

Temperature Converter Solution

felo
felo 



find attached solution Attachments
TEMPCONVERTERHTML.png (45 K) Download Preview

tempconv.HTML (1 K) Download Preview
temperature measure"); document.getElementById("temp").focus(); return false; } result = 9.0/5.0*(parseFloat(document.getElementById("temp").value)+32); alert(document.getElementById("temp").value+"\xB0 Celsius is equivalent to "+parseFloat(result).toFixed(2)+"\xB0 Fahrenheit") } </script> </head> <body> <h2>Please type a temperature measure and push the correspondent button to convert it.</h2> <hr>

Screenshots
Screenshot
Purchase Answer