Welcome to the Cumulus Support forum.

Latest Cumulus MX release 3.28.5 (build 3282) - 23 February 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

Javascript + dynamic meter value

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

Moderator: daj

Post Reply
Mapantz
Posts: 1770
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Javascript + dynamic meter value

Post by Mapantz »

I've been playing around with the html meter tag to make a meter for certain rain totals, whilst that is straight forward, the next step is to make the meter read a dynamic value with Javascript.

At the moment, I did it in the inefficient and long way, with an example below:

Code: Select all

  var rdayMeter = x.getElementsByTagName("rdaymeter")[0].childNodes[0].nodeValue;
  if (rdayMeter < 0.0) { document.getElementById("rdaymeter").innerHTML = '<meter value="0" min="0" max="25"></meter>'; }
  if ((rdayMeter >= 0.1) && (rdayMeter <= 5)) { document.getElementById("rdaymeter").innerHTML = '<meter value="5" min="0" max="25"></meter>'; }
  if ((rdayMeter >= 5.1) && (rdayMeter <= 10)) { document.getElementById("rdaymeter").innerHTML = '<meter value="10" min="0" max="25"></meter>'; }
I then put <span id="rdaymeter"></span> in the html file to get the meter bar.

I know there is a better way to do it, but that's where I am stuck. :oops:

How can I populate meter value=" " with the exact value that is being supplied?
Image
Post Reply