Page 1 of 1

Truncate Webtag Value

Posted: Sun 02 Sep 2018 3:44 pm
by Herbaldew
When using the webtag for extra temp 1, the value returned has a decimal and a zero, and it displays as eg "81.0".

How can I make it drop the decimal and tenths position, and make it display as eg "81"? In the case of Davis anyway, the extra temp sensors only return full numbers, no tenths thus making the tenths column superfluous.


Thanks

Re: Truncate Webtag Value

Posted: Mon 03 Sep 2018 4:11 pm
by mcrossley
Depends on how you present the data. Cumulus can't do it for you, so if you use PHP to construct the page, reformat the data in PHP, failing that you will have to use JavaScript in the browser.

Re: Truncate Webtag Value

Posted: Tue 04 Sep 2018 1:47 pm
by Herbaldew
Thanks. After a good bit of frustration, I did it with JavaScript.

I was trying to work this out on Internet Explorer as it is what I use for my CMX interface. Turns out that Math.trunc doesn't work on IE :( Using Math.floor instead produced the desired result :)

Re: Truncate Webtag Value

Posted: Tue 04 Sep 2018 3:05 pm
by sfws
Herbaldew wrote: I did it with JavaScript.

I was trying to work this out on Internet Explorer
Strictly speaking Microsoft Internet Explorer uses "jScript" (not "JavaScript" as implemented by other browsers).
Although both script languages now follow the European Computer Manufacturers Association 262 Script Standard, they implement different editions of that standard, so there will be some syntax differences, as you have discovered, and there are also differences between IE versions (research for yourself if you want more details).
The popularity of libraries like jQuery is because they allow you to write code that works in multiple browsers (and other agents) regardless of which ECMA edition they implement and it also allows for variance in the extent to which older and newer browser versions conform to the standard.