Convert Daily Range Between Fahrenheit and Celsius
Posted: Fri 05 Jul 2013 7:36 pm
On my weather webpages, I use a small script to convert Fahrenheit to Celsius (or vice versa) so both temperatures are shown as Fahrenheit | Celsius. Using the example of the year's highest temperature, here is the HTML code I use to show both Fahrenheit and Celsius using Celsius data:
And here is the same thing using Fahrenheit data:
The problem I running into using these codes deals with the daily ranges. I know they are determined by subtracting the low from the high temperature, but there must be a way to do it to where I can show the range as both Fahrenheit and Celsius. I cannot figure out a way to do this Might someone out there know?
Code: Select all
<script>tempF1 = <#YearTempH> * 1.8 + 32;document.write(tempF1.toFixed(0));</script> °F | <#YearTempH> <#tempunit>
Code: Select all
<#YearTempH> <#tempunit> | <script>tempC1 = (<#YearTempH> - 32) / 1.8;document.write(tempC1.toFixed(1));</script>