Hello there,
I am hoping that somebody will be able fix me up with a little bit of code (I am not even sure if what I am wanting to do is possible). I would like to be able to change the text colour of the <#temp> and <#tempunit> outputs from their current green to say red when the value of the <#temp> tag reaches 38°C. For the want of a better term I would think that this would be considered 'conditional formatting'.
<td width="44%"align="left"valign="center"style="font-size:1400%"style="color:#228B22"><#temp><#tempunit></td>
http://home.exetel.com.au/retnuh/weather/lite.htm
I would imagine that if it can be done the code would be inserted in the line just prior to (style="color:#228B22").
Any help is greatly appreciated.
Alan
Welcome to the Cumulus Support forum.
Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025
Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024
Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)
Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki
If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080
Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025
Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024
Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)
Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki
If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080
Conditional Formatting
Moderator: daj
-
sfws
- Posts: 1183
- Joined: Fri 27 Jul 2012 11:29 am
- Weather Station: Chas O, Maplin N96FY, N25FR
- Operating System: rPi 3B+ with Buster (full)
Re: Conditional Formatting
(deleted due to errors in suggested code)
Last edited by sfws on Mon 03 Aug 2015 11:21 am, edited 1 time in total.
-
Alan
- Posts: 51
- Joined: Sun 14 Mar 2010 9:41 am
- Weather Station: WH1091
- Operating System: Win 7
- Location: Sydney
Re: Conditional Formatting
Thank you sfws, I inserted your suggested code but unfortunately the text is now black whilst <#temp> is under 38° instead of the usual green. I have experimented with your code and changed the 38° to 15° which is way below current temp to see if it would change to red but no, no go, still black.
At a loss, cheers!
At a loss, cheers!
- beteljuice
- Posts: 3292
- Joined: Tue 09 Dec 2008 1:37 pm
- Weather Station: None !
- Operating System: W10 - Threadripper 16core, etc
- Location: Dudley, West Midlands, UK
Re: Conditional Formatting
Small errors in swfs code (been there, done that
)
The colour red is attributed for both sides of the argument, and in splitting the code the quotes syntax is incorrect.
Try:(Untested) I've made the code so it will a bit easier for you to edit, and given you a 'cold' option.
However; you do have more than one temperature on the 'page', and as written this will only work for one (the id 'panel'). It would be better written as function call if you want more than one coloured temperature.
The colour red is attributed for both sides of the argument, and in splitting the code the quotes syntax is incorrect.
Try:
Code: Select all
<script type="text/javascript">
var code_segment;
if(<#temp> >=38){
code_segment='<span style="color: red"><#temp><#tempunit></span>';
}
if(<#temp> <=0){
code_segment='<span style="color: blue"><#temp><#tempunit></span>';
}
var panel=document.getElementById("panel");
panel.innerHTML=code_segment;
</script>However; you do have more than one temperature on the 'page', and as written this will only work for one (the id 'panel'). It would be better written as function call if you want more than one coloured temperature.
......................Imagine, what you will KNOW tomorrow !
-
Alan
- Posts: 51
- Joined: Sun 14 Mar 2010 9:41 am
- Weather Station: WH1091
- Operating System: Win 7
- Location: Sydney
Re: Conditional Formatting
Great, thank you very much. Picked up the gist and applied small mods and additions so as to comply with my required temperature range and switching points. Works beautifully!!
Thanks and cheers!!
Thanks and cheers!!