I have the following situation: Fiddle
What I want, is to add an onChange
event to the dropdown boxes of the datepicker
so that I will be able to capture the selected month/year in the text box above as a new value is selected from the calendar.
PS: Inspecting the relevant dropdown boxes, there is already an onChange
command assigned that looks like
onchange="DP_jQuery_1353406309923.datepicker._selectMonthYear('#datepicker', this, 'M');"
I don't want to overwrite this.
Thanks in advance
Use the onChangeMonthYear
option:
onChangeMonthYear
Called when the datepicker moves to a new month and/or year. The function receives the selected year, month (1-12), and the datepicker instance as parameters. this refers to the associated input field.
$(function() {
$( "#datepicker1" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'MM yy',
altField: "#id",
altFormat: "mm/yy",
onChangeMonthYear: function(year, month, oDatepicker) {
alert('Year: ' + year + ', Month: ' + month);
}
});
});
Your fiddle, updated: http://jsfiddle.net/ff6Ex/1/