Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4017) - 17 March 2024

Legacy Cumulus 1 release v1.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

HTML "wood for the trees" issue!!

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

Moderator: daj

Post Reply
User avatar
mikechristelow
Posts: 165
Joined: Wed 01 Feb 2012 9:33 pm
Weather Station: Watson W8681 (solar)
Operating System: Windows XP SP3
Location: Crewe, Cheshire
Contact:

HTML "wood for the trees" issue!!

Post by mikechristelow »

I'm trying to create a line of code for one of my pages which says whether it's sunny, what the UV Index is, a description for the index value and an image selected to reflect the severity of the image.

If I write

Code: Select all

document.write(<#UV>+" ("+uv_name+")");
where <#UV> is the webtag and uv_name is a variable assigned in a javascript to indicate the UV index severity (Low, Moderate, high etc) I get Image
as expected (the UV value being 1 at the time).

If I write

Code: Select all

document.write('It is overcast at the moment and current UV Index is <#UV>+" ("+uv_name+")"+<img src="images/UV_index/uv_index_<#UV>.png" width="11" height="11" alt="UV index" title="UV index" /> .')
I get this Image.

In otherwords, the variable uv_name is being presented literally rather than it's value being shown.

The full javascript is this:

Code: Select all

					<!-- Description of sunshine and UV conditions - only output if sun is up -->
					<script type="text/javascript">
						<!-- Description of sunshine conditions -->
						var is_sun_up = <#IsSunUp>;
						var is_sunny = <#IsSunny>;
						var uv_val = <#UV>;
						var uv_name = "";
						switch(true)
						{
						case uv_val == 0:
						var uv_name = "No Risk";break;
						case uv_val <= 2:
						var uv_name = "Low";break;
						case uv_val <=  5:
						var uv_name = "Moderate";break;
						case uv_val <=  7:
						var uv_name = "High";break;
						case uv_val <=  10:
						var uv_name = "Very High";break;
						case uv_val >=  11:
						var uv_name = "Extremely High";break;
						}						
						if (is_sun_up == 1) 
							{
							<!-- Description of sunshine conditions -->							
							if (is_sunny == 0) // Not Sunny
								{
								document.write('It is not sunny at the moment and current UV Index is <#UV>+" ("+uv_name+")"+<img src="images/UV_index/uv_index_<#UV>.png" width="11" height="11" alt="UV index" title="UV index" /> .')								
								}
							else
								if (is_sunny == 1) // Sunny
									{
										document.write("It's sunny at the moment and current UV Index is "+uv_name+".");
									}							
							}				
					</script>			
You'll see that the output for when it is sunny is simpler and this works.

I'm sure this must be something to do with nested quotes or something but I can't get this to work and need another pair of eyes on it. Any suggestions gratefully received!
http://www.christelow.co.uk
“It's snowing still," said Eeyore gloomily.
"So it is."
"And freezing."
"Is it?"
"Yes," said Eeyore. "However," he said, brightening up a little, "we haven't had an earthquake lately.”

User avatar
steve
Cumulus Author
Posts: 26702
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: HTML "wood for the trees" issue!!

Post by steve »

I can't see the images, but you are swapping quote types when you're not actually nesting, e.g. this quote

Code: Select all

<#UV>+"
should be the same as your opening quote

Code: Select all

<#UV>+'
Only the quotes in your <img ... /> construct need to be double quotes. You also have a missing quote before your <img tag (which you can simplify anyway):

Code: Select all

document.write('It is overcast at the moment and current UV Index is <#UV>+' ('+uv_name+')<img src="images/UV_index/uv_index_<#UV>.png" width="11" height="11" alt="UV index" title="UV index" /> .')
Steve
User avatar
mikechristelow
Posts: 165
Joined: Wed 01 Feb 2012 9:33 pm
Weather Station: Watson W8681 (solar)
Operating System: Windows XP SP3
Location: Crewe, Cheshire
Contact:

Re: HTML "wood for the trees" issue!!

Post by mikechristelow »

Thank you Steve - it's amazing what you can't see until someone else has a look at it!
Much appreciated,
Mike
http://www.christelow.co.uk
“It's snowing still," said Eeyore gloomily.
"So it is."
"And freezing."
"Is it?"
"Yes," said Eeyore. "However," he said, brightening up a little, "we haven't had an earthquake lately.”

Post Reply