Page 1 of 1

Display values in more than one unit

Posted: Mon 29 Nov 2010 6:02 am
by sunray24
Is it possible to display a value but show it with more than one unit?
Example: say I wanted to display temperature on my website but wanted to show the value in Celcius AND Fahrenheit.
It would look like 37.8 C (100 F) for example

Scott

Re: Display values in more than one unit

Posted: Mon 29 Nov 2010 7:06 am
by captzero
Scott,

You can do that with some simple javascript. I do it with wind speed (kph/knots).

Using the outdoor temperature webtag something like the following should work:

(<script type="text/javascript">
var tempC = "<#temp> ";
var tempF = Math.abs((9/5)*tempC+32);
document.write(tempF.toFixed(1));
</script>°F)

This will put it in brackets with the °F. There are probably other ways to do it as well.

I like to use an online html editor to check my javascript and use http://www.onlinehtmleditor.net/

Re: Display values in more than one unit

Posted: Mon 29 Nov 2010 2:02 pm
by sunray24
Dan

That's brilliant!
Just added the code into my webpage and it works perfectly
Thanks again

Scott
http://www.glenforrestweather.com/