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 4019) - 03 April 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

Problem tags #ryear within the script in Javascript

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

Moderator: daj

Post Reply
mitmania
Posts: 38
Joined: Tue 07 Feb 2012 11:51 am
Weather Station: WS2350 & Davis VP2
Operating System: Win 7
Location: Italy
Contact:

Problem tags #ryear within the script in Javascript

Post by mitmania »

Hello, everyone. I have the following problem: I use the old version of Cumulus 1.9 and in the indexT.htm page I have inserted a javascript script to make comparisons in the rain value. My problem is that I cannot get in any way the numerical value of the #ryear tags to be inserted inside the script. Am I going down the wrong path ? Is this possible ? Thanks to those who can give me some answers.
User avatar
mcrossley
Posts: 12779
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Problem tags #ryear within the script in Javascript

Post by mcrossley »

I think it would help if you posted your script and an indication of the lines causing the problem.
mitmania
Posts: 38
Joined: Tue 07 Feb 2012 11:51 am
Weather Station: WS2350 & Davis VP2
Operating System: Win 7
Location: Italy
Contact:

Re: Problem tags #ryear within the script in Javascript

Post by mitmania »

Hi, I attach the indexT.htm code of my web page. I can't use the value of the #ryear tag to use within the script. Currently I calculate only a theoretical value of rainfall.

Code: Select all

!-- Sez_Rain_Wind_line_5 -->
                             <tr class="td_temperature_data">
                             <td><font size="3">Descrizione</font></td>
                             <td><#beaudesc></td>
                             <td><font size="3">&nbsp;&nbsp;&nbsp;Pioggia anno</font></td>
                             <td><#ryear>&nbsp;<#rainunit></td>
                             </tr>
<!-- Sez_Rain_Wind_line_6 -->
                             <tr class="td_temperature_data">
                             <td><font size="3">Direzione dominante vento</font></td>
                             <td><#domwindbearing>°</td>
                             <td><font size="3">&nbsp;&nbsp;&nbsp;Giorni dall'ultima pioggia (> 0.2mm)</font></td>
                             <td><#ConsecutiveDryDays></td>
                             </tr>
<!-- Sez_Rain_Wind_line_7 -->
                             <tr class="td_temperature_data">
                             <td><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></td>
                             <td></td>
                             <td><font size="3">&nbsp;&nbsp;&nbsp;Pioggia teorica dall'inizio anno </font></td>
                             <td><span id="valore"></span>&nbsp;<#rainunit></td>
                             <td>
                              <script type="text/javascript">
                                 var oggi = new Date();
                                 var inizioAnno = new Date(oggi.getFullYear(), 0, 1); // 1 = gennaio
                                 var differenzaTempo = oggi.getTime() - inizioAnno.getTime();
                                 var differenzaGiorni = Math.floor(differenzaTempo / (1000 * 60 * 60 * 24));
                                 var pre_media_anno = 1214.1  // valore dal 2010 al 2022
                                 var pre_media_giorno_teo = 3.3217  // valore teorico 
                                 var pre_giornox_teo = pre_media_giorno_teo * differenzaGiorni;
                                 var pre_giornox_teo_int = Math.floor(pre_giornox_teo);
                                 document.getElementById("valore").innerHTML = pre_giornox_teo_int;
                               </script></td>
                             </tr>
User avatar
mcrossley
Posts: 12779
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Problem tags #ryear within the script in Javascript

Post by mcrossley »

If you are using a decimal numeric web tag in a script with a comma decimal locale, then you must convert the comma to a full stop before it is used.

Cumulus MX can do this for you, but with C1 you will have to assign the value to a variable as text and then do a replace on ',' to '.' before you use the variable in a calculation.
mitmania
Posts: 38
Joined: Tue 07 Feb 2012 11:51 am
Weather Station: WS2350 & Davis VP2
Operating System: Win 7
Location: Italy
Contact:

Re: Problem tags #ryear within the script in Javascript

Post by mitmania »

OK ....Thank you very much for your reply. This evening I will put into practice what you have indicated to me to do. Thanks again!
Post Reply