Buenas tardes. En mi proyecto, necesito mostrar un calendario por un año. Lo hice con selector de fechas. Ahora necesito hacerlo para poder seleccionar el año de este calendario desde otra página. ¿Por favor dime cómo hacer esto? (Un año llega a la página con una solicitud)
function drawDatepicker(){ $('#picker').datepicker({ showOtherMonths: true, selectOtherMonths: true, numberOfMonths: [3,4], stepMonths: 0, yearRange: chouseYear + ":" + chouseYear, showCurrentAtPos: new Date().getMonth(), onSelect: function (dateText, datePicker) { datePicker.drawMonth += $("#picker").datepicker("option", "showCurrentAtPos"); var radVal = $('input[name="typeDay"]:checked').val(); if(radVal == 1){ addOrRemoveDate(dateText, day_off); } if(radVal == 2){ addOrRemoveDate(dateText, radonica); } console.log(day_off); console.log(radonica); }, beforeShowDay: function (date) { var year = date.getFullYear(); var month = padNumber(date.getMonth() + 1); var day = padNumber(date.getDate()); var dateString = day + "." + month + "." + year; var gotDate1 = jQuery.inArray(dateString, day_off); if (gotDate1 >= 0) { return [true, "ui-state-highlight"]; } var gotDate2 = jQuery.inArray(dateString, radonica); if (gotDate2>=0){ return [true, "ui-widget-header"]; } return [true, ""]; } }); }Encontré esta solución al problema. Especifiqué defaultDate 01.01 del año deseado y showCurrentAtPos a 0. Si se especifica el año actual, entonces defaultDate es hoy y showCurrentAtPos es el número del mes.
defaultDate: defaultDate, showCurrentAtPos: sCAPos,