You could do it in the Cheetah template. Something like this (NOT TESTED):

#set rules = ["Mostly clear and cooler.", "Mostly clear with little
temperature change.", "Mostly clear for 12 hours with little temperature
change.", ... , ]

<tr>
    <td>The forecast is: </td>
    <td>$rules[$current.forecastRule.raw]</td>
<tr>

-tk

On Thu, Nov 14, 2019 at 1:39 PM PJD <[email protected]> wrote:

> I'm trying to write code that will take Davis's forecastRule (a number)
> and display this on my webpage as text by reading the number off an array
> and returning the text corresponding to that number.
>
> For example if the Davis forecastRule returned is 5, I want the webpage to
> display "Partly cloudy and cooler" which is the corresponding forecast in
> text form.
>
> I'm not sure on the best way to do this but am trying to do it with
> Javascript with instructions to pull the text from an external text file
> (set up as a JS array) containing the nearly 200 text strings.
>
> I'm getting bogged down with the syntax and would appreciate any help.
> Should I be doing it a different way ie not using JS?
>
> I don't know how to declare the variable if the array lives in an external
> file.
>
> Thanks for any help!
>
> PJD
>
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/f562b9c5-c551-45b2-a9a4-25848d847aad%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-user/f562b9c5-c551-45b2-a9a4-25848d847aad%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CAPq0zECtZFC5BUkbCyrMzvio00Y%2B2bSqPaCXk6w1JNFzAmo5wg%40mail.gmail.com.

Reply via email to