I try to insert the names of selected days from datepicker, to two input fields.
$("#date_from, #date_to").datepicker({
defaultDate
: "+1d",
minDate
: "+1d",
changeMonth
: true,
changeYear
: true,
dateFormat
: "dd/mm/yy",
monthNamesShort
: ["Sty", "Lut", "Mar", "Kwi", "Maj", "Cze", "Lip", "Sie", "Wrz", "Paz", "Lis", "Gru"],
dayNamesMin
: ["Nie", "Pon", "Wt", "Śr", "Czw", "Pt", "Sob"],
numberOfMonths
: 1,
constrainInput
: true,
beforeShowDay
: noWeekendsOrHolidays,
firstDay
: 1, // Start with Monday
onSelect
: function (dateText, inst) {
if (this.id == 'date_from') {
var dateMin = $('#date_from').datepicker("getDate");
var dateMax = $('#date_to').datepicker('getDate');
var rent_date_from = new Date(dateMin.getFullYear(), dateMin.getMonth(), dateMin.getDate() + 1);
var rent_date_to = new Date(dateMin.getFullYear(), dateMin.getMonth(), dateMin.getDate() + 29);
$
('#date_to').datepicker("option", "minDate", rent_date_from);
$
('#date_to').datepicker("option", "maxDate", rent_date_to);
}
$
('#day_of_week1').val($.datepicker.formatDate('DD', dateMin));
$
('#day_of_week2').val($.datepicker.formatDate('DD', dateMax));
compute
(); //Add compute
}
});
For now, I get a value but only from the first field (in the #day_of_week1
), but I can't get the value from the second one. I don't know where is the problem?
Thanks for any help.