Page 1 of 1

Apparent Temperature

Posted: Wed 12 Sep 2012 5:55 am
by Alan
Hello All,
I started out with what I thought was going to be a simple task. I simply wanted to incorporate into my web page a readout of the Apparent Temp expressed as xx.x C° cooler/warmer than the actual temp (ie the difference between Temp and Apptemp). Functionally it is quite ok. However, the result is a number with 16 decimal places. I am not quite sure why this might happen considering that both Temp and Apptemp are only 1 decimal place numbers. I am hoping that somebody might be able to help me with code so that the result is also a 1 decimal point number. I have spent many frustrating hours trying to fix this but all to no avail.
All the best
Alan

Code: Select all

<table class="data" width="1900px" border="0" cellpadding="0" cellspacing="0" align="center">  
  <tr>	  
    <td width="44%"align="right" valign="center"style="font-size:300%"style="color:#228B22"><u>Temperature, Inside</u></td>
    <td width="12%"align="center"valign="center"></td>
		<td width="44%"align="left"valign="center"style="font-size:300%"style="color:#228B22"><u>Temperature, Outside</u></i></td>
	  </tr>
	<tr>	  
    <td width="44%"align="right"valign="center"style="font-size:1500%"style="color:#228B22"><#intemp><#tempunit></td>
		<td width="12%"align="center"valign="center"style="font-size:140%"style="color:#228B22"><u>Apparent Temp</u><br /><br /><p>< font size="6">
		                                                                                                                                          [color=#0000FF] <script type="text/javascript">
																																																																							 var a=<#temp>;
																																																																							 var b=<#apptemp>;
																																																																							 if(a>=b)
																																																																							 document.write(a-b + "C°" + "<br>" + "cooler")
																																																																							 if(a<b) 
																																																																							 document.write(b-a + "C°" + "<br>" + "warmer") 
																																																																							 </script></td>	[/color]	                                                                                                                                     
		<td width="44%"align="left"valign="center"style="font-size:1500%"style="color:#228B22"><#temp><#tempunit></td>
		</tr>		 
</table> 
[urlhttp://home.exetel.com.au/retnuh/weather/lite.htm][/url]

Re: Apparent Temperature

Posted: Wed 12 Sep 2012 8:42 am
by mcrossley
(a-b).toFixed(1) + "C°" + "<br>" + "cooler"

Re: Apparent Temperature

Posted: Wed 12 Sep 2012 9:35 am
by beteljuice
You have some <td errors

typically:

<td width="100%"" align="center" <p><font size="7" ......... no closing >

eg.

<td width="100%"" align="center"> <p><font size="7"

Re: Apparent Temperature

Posted: Wed 12 Sep 2012 12:46 pm
by Alan
Hello Mark,
Thank you very much for your response. I tried your suggested code but unfortunately it made no difference. However, I believed that even with my limited knowledge, I could sense that something was afoot. I do not know how or why exactly, but something told me to bracket the code that you supplied... Bingo!

(a-b).toFixed(1) + "C°" + "<br>" + "cooler"
((a-b).toFixed(1) + "C°" + "<br>" + "cooler")

It now works beautifully,
Thank you ever so much for your help.
Alan