If I write
Code: Select all
document.write(<#UV>+" ("+uv_name+")");
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" /> .')
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>
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!