Board Logo

How to show just months
CommandoS - 4/24/2010 at 06:02 PM

Hey


When I select any day it gives me; (month/day/year) example 03/30/2010

but I just want; (month/year) example 03/2010

so how can I do it ?


Rukbat - 6/4/2010 at 08:15 PM

I had a similar problem, I needed one calendar to show me the first of the month, no matter what date the user chose. (The database uses a date field, but it has to be forced to the first - not my design.)

In f_tcalGenerDate, I added code to check whether my new variable, monthtype, is defined. If it is I return month/01/year, otherwise I return the selected date.

Code:

function f_tcalGenerDate (d_date) {
var i =
(d_date.getMonth() < 9 ? '0' : '') + (d_date.getMonth() + 1) + "/"
if (this.a_cfg.monthtype) { //this is my new variable
i += '01/';
} else {
i += (d_date.getDate() < 10 ? '0' : '') + d_date.getDate() + "/"
}
i += d_date.getFullYear()
return i;
}

I use the variable like this:
Code:

new tcal ({
'formname': 'sftc',
'controlname': 'smdate',
'monthtype' : true,
'today': m+'/01/'+y
});


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/