Page 1 of 1
Dual unit display
Posted: Mon 09 Jan 2012 7:55 pm
by R-II
Simple question I hope..
Can I have Sea Level pressure displayed in both mb and inch on my web page and how easy is it to implement
Somebody commented that mb is more common now and they would prefer to see it that way, rather than edit a years worth of data by changing my system settings I thought I may be able to display both
Ie Pressure 30.12in (997mb) or something like
Re: Dual unit display
Posted: Tue 10 Jan 2012 12:46 am
by beteljuice
If you are talking about the 'standard' html templates you would need to add some JavaScript to do the math for the additional unit.
This bit of code should give whatever the alternative unit is for your current pressure:
Code: Select all
<script type="text/javascript">
<!--
function showAltBaro(input) {
if(<#pressunit> == "in"){ // convert to hPa
output = (input * 33.86388).toFixed(1);
output += " hPa";
}else{ // convert to inHG
output = (input / 33.86388).toFixed(2);
output += " inHG";
}
document.write(output);
} // END function showAltBaro
-->
</script>
and your html would be something like:
Code: Select all
.....
Pressure <#press> <#pressunit> (<script>showAltBaro(<#press>);</script>)
.....
Ooops - just realised <#pressunit> option should be 'in' NOT 'inHG' - corrected
Re: Dual unit display
Posted: Tue 10 Jan 2012 7:59 am
by R-II
Thanks, i found a way to do it after much fiddling but will try yours to see the effect.
I'm learning as I go along, my next step is to get the gauge to show alternate units via a radio button
Thanks again
Re: Dual unit display
Posted: Tue 10 Jan 2012 12:25 pm
by beteljuice
ATM you've 'lost' a table cell.
If you try my code (which I've corrected an error in

), then try this chunk of html:
Code: Select all
<tr class="td_pressure_data">
<td>Barometer </td>
<td><#press> <#pressunit><br /><script>showAltBaro(<#press>);</script></td>
<td><#presstrend></td>
<td><#presstrendval> inHG/hr<br /><script>showAltBaro(<#presstrendval>);</script>/hr</td>
</tr>
Re: Dual unit display
Posted: Tue 10 Jan 2012 12:37 pm
by scoobs
Hi Richard get yourself an account on the Met office wow site too

be nice to have another station near to compare results.
Re: Dual unit display
Posted: Tue 10 Jan 2012 2:50 pm
by R-II
beteljuice wrote:ATM you've 'lost' a table cell.
The loss of cell was deliberate ... well it happened by accident and I quite liked the result, but when i get home i'll have a play with the code
Re: Dual unit display
Posted: Tue 10 Jan 2012 2:50 pm
by R-II
scoobs wrote:Hi Richard get yourself an account on the Met office wow site too

be nice to have another station near to compare results.
Will do, glad to see a local face about
