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

error and new record lights

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Post Reply
Alan
Posts: 51
Joined: Sun 14 Mar 2010 9:41 am
Weather Station: WH1091
Operating System: Win 7
Location: Sydney

error and new record lights

Post by Alan »

Hello all, I am hoping that somebody may be able to help me with the code for this small problem that I have. I am incorporating red or green lights into a table and that works fine but what I would also like to be able to do is incorporate both red and green lights alongside each other when the condition var x=11 is met. The alternative to not being able to do this is to use a third color for condition 11. After a heck of a lot of experimenting and researching I am still unsuccessful and at a loss. Help would be greatly appreciated.
Thanks in advance.
Alan

<table class="data" width="auto" height="45px" border="0" cellpadding="0" cellspacing="0" align="center">

<td valign="bottom"><script type="text/javascript">
var x=11 <!--<#ErrorLight><#newrecord>/!-->
if (x == "10") {var pictures = "redlight.png";}
if (x == "01") {var pictures = "greenlight.png";}
if (x == "11") {var pictures = "redlight.png";}
{var pictures = "greenlight.png";} (in this arrangement of course only the green light remains active)

if (x == "00") {var pictures = "greenlight.png";hidden}
document.write('<img src="http://home.exetel.com.au/retnuh/weathe ... '+pictures+'"/>');
</script></td>
</table>
User avatar
MickinMoulden
Posts: 499
Joined: Mon 20 Dec 2010 12:12 pm
Weather Station: WS-1081 with rain gauge mod
Operating System: Windows 7 & 1.9.3 b1059
Location: Palmerston, NT, Australia
Contact:

Re: error and new record lights

Post by MickinMoulden »

Alan wrote:Hello all, I am hoping that somebody may be able to help me with the code for this small problem that I have. I am incorporating red or green lights into a table and that works fine but what I would also like to be able to do is incorporate both red and green lights alongside each other when the condition var x=11 is met. The alternative to not being able to do this is to use a third color for condition 11. After a heck of a lot of experimenting and researching I am still unsuccessful and at a loss. Help would be greatly appreciated.
Thanks in advance.
Alan

<table class="data" width="auto" height="45px" border="0" cellpadding="0" cellspacing="0" align="center">

<td valign="bottom"><script type="text/javascript">
var x=11 <!--<#ErrorLight><#newrecord>/!-->
if (x == "10") {var pictures = "redlight.png";}
if (x == "01") {var pictures = "greenlight.png";}
if (x == "11") {var pictures = "redlight.png";}
{var pictures = "greenlight.png";} (in this arrangement of course only the green light remains active)

if (x == "00") {var pictures = "greenlight.png";hidden}
document.write('<img src="http://home.exetel.com.au/retnuh/weathe ... '+pictures+'"/>');
</script></td>
</table>
You are putting x as being 11, it will never be 10 or 01. It will always show a red light. Just put var x=<#ErrorLight><#newrecord>/ .
Also, with the qoutations it needs more work adding in the backslash like:

Code: Select all

document.write('<img src=\"http://home.exetel.com.au/retnuh/weather/images/pictures/'+pictures+'\"/>');
     </script></td> 
Alternatively, why don't you just make a picture of two lights together for each of the scenarios and skip all the Javascript altogether and just have
<img src="http://home.exetel.com.au/retnuh/weathe ... ecord>.png">
Michael, Palmerston, NT Australia www.Palmerston-WeatherImageNo image? I'm offline!
ImageImage
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: error and new record lights

Post by mcrossley »

Or have...

<img src="images/pictures/red<#ErrorLight>.png"><img src="images/pictures/green<#newrecord>.png">

With the following images in your images folder..

red0.png = "red off"
red1.png = "red on"
green0.png = "green off"
green1.png = "green on"
Alan
Posts: 51
Joined: Sun 14 Mar 2010 9:41 am
Weather Station: WH1091
Operating System: Win 7
Location: Sydney

Re: error and new record lights

Post by Alan »

Thank you Michael and Mark for your efforts,

I can see Mark that your suggestion would work beautifully. However, since posting my original request for help I have ploughed on and managed to achieve the required results, albeit via a far more cumbersome fashion of code.

<table class="data" width="100%" height="45px" border="0" cellpadding="0" cellspacing="0" align="center">

<td width="100%"align="center"valign="bottom"><script type="text/javascript">
var x=<#ErrorLight><#newrecord>
if (x == "10")
document.write('<img src="http://home.exetel.com.au/retnuh/weathe ... dlight.png"/>');

var x=<#ErrorLight><#newrecord>
if (x == "01")
document.write('<img src="http://home.exetel.com.au/retnuh/weathe ... nlight.png"/>');

var x=<#ErrorLight><#newrecord>
if (x == "11")
document.write('<img src="http://home.exetel.com.au/retnuh/weathe ... dlight.png"/>');
document. write('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
if (x == "11")
document.write('<img src="http://home.exetel.com.au/retnuh/weathe ... nlight.png"/>');

var x=<#ErrorLight><#newrecord>
if (x == "00")
document.write('<img src="http://home.exetel.com.au/retnuh/weathe ... '+pictures+'"/>');
</script></td>
</table>

Thanks and cheers!
Alan
Post Reply