Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 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

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

Default to current month in monthlyrecord.htm

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

Moderator: daj

Post Reply
User avatar
MackerelSky
Posts: 141
Joined: Fri 01 Apr 2011 8:14 pm
Weather Station: Davis VP2 w/FARS
Operating System: Toshiba Laptop Windows 7 x64
Location: Smethport, Pa.
Contact:

Default to current month in monthlyrecord.htm

Post by MackerelSky »

Hi Steve/All,

I might have missed this in a search, but here goes

I've created a mwmonthlyrecordT.php and have it being processed by Cumulus and uploaded to my site as

http://www.mckeanweather.com/mwmonthlyrecord.php

It works great with all of the correct info inserted as far as I can tell.

My question, what would it take code wise to have it default to the current month that we are in instead of loading on the month of January.

I use the same script that comes inside the monthlyrecordT.htm file furnished from Steve

I've gotten the date_object.getMonth() to give me the correct month, ie: 0-11, currently (1) for February but I can't for the life of me figure out how to get it into the function changeData(month) or directly into the onclick="changeData(1)"

I'm just thinking that it would be nicer to load to the current month and maybe there could be other folks that would like the same thing. Would appreciate any help on the topic

Brad
Davis VP2/FARS
Cumulus 1.9.4(1092)

McKean Weather
'cause not everyone lives at the airport

Image
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Default to current month in monthlyrecord.htm

Post by mcrossley »

A bit like mine?
http://weather.wilmslowastro.com/monthlyrecord.htm

Just need to put a call to changeData() at the end of the script...

changeData(+'<#month>' - 1);
Last edited by mcrossley on Sun 16 Feb 2014 5:21 pm, edited 1 time in total.
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Default to current month in monthlyrecord.htm

Post by steve »

Mark has done that on his page: http://weather.wilmslowastro.com/monthlyrecord.htm

Edit: The forum didn't warn me that there had been another post (again).
Steve
User avatar
MackerelSky
Posts: 141
Joined: Fri 01 Apr 2011 8:14 pm
Weather Station: Davis VP2 w/FARS
Operating System: Toshiba Laptop Windows 7 x64
Location: Smethport, Pa.
Contact:

Re: Default to current month in monthlyrecord.htm

Post by MackerelSky »

mcrossley wrote:A bit like mine?
Thanks Mark,

Even after your edit(lol) I couldn't get it to work...

Does it have something to do with the 'extra' code you have in your Page?

Code: Select all

function changeData(month) {
	for (fld in values) {
    if (fld.substring(0,4) === 'Rec_') {
      document.getElementById(fld).src = '/images/newRec-' + values[fld][month] + '.png';
    } else {
		  document.getElementById(fld).innerHTML = values[fld][month];
    }
	}

I understand that the code mainly has to do with your image for all time record but does it also do something for the current month?
Brad
Davis VP2/FARS
Cumulus 1.9.4(1092)

McKean Weather
'cause not everyone lives at the airport

Image
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Default to current month in monthlyrecord.htm

Post by mcrossley »

I can't see what you have put in the source, but the effect is to produce this...

changeData(+'' - 1);

The month number is missing. Do you have the tag right? <#month>
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Default to current month in monthlyrecord.htm

Post by mcrossley »

Oh, and ignore my code, I have just streamlined the function a bit to loop through the spans rather than set them explicitly as the original code does.
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Default to current month in monthlyrecord.htm

Post by mcrossley »

Oh, one other thing, you need to move the script block from the page header to the end of the document, otherwise it will be trying to set the values before the browser has created them.
User avatar
MackerelSky
Posts: 141
Joined: Fri 01 Apr 2011 8:14 pm
Weather Station: Davis VP2 w/FARS
Operating System: Toshiba Laptop Windows 7 x64
Location: Smethport, Pa.
Contact:

Re: Default to current month in monthlyrecord.htm

Post by MackerelSky »

mcrossley wrote:Oh, one other thing, you need to move the script block from the page header to the end of the document, otherwise it will be trying to set the values before the browser has created them.
That's what was wrong, seems to be working now.

Thanks for your time

Brad

*edit*
Thanks to you too Steve
Davis VP2/FARS
Cumulus 1.9.4(1092)

McKean Weather
'cause not everyone lives at the airport

Image
Post Reply