0

I am stuck in JQuery Calendar

i have a drop down who have list of cities

<select name="flyto_code" id="flyto_code">
    <option value="ISB">Islamabad (ISB)</option>
    <option value="KHI">Karachi (KHI)</option>
</select>

and i have dynamic (came from ajax) array filled with the dates like..

var availableDatesForKhi = ["12-10-2013","13-10-2013","14-10-2013","15-10-2013","16-10-2013","17-10-2013","18-10-2013"];
var availableDatesForIsb = ["12-11-2013","13-10-2013","14-11-2013","15-10-2013","16-11-2013","17-10-2013","18-11-2013"];

when i select KHI from dropbox DatePicker should enable availableDatesForKhi

$( "#departure_date" ).datepicker({
beforeShowDay: available,
numberOfMonths:1,
showWeek: true,
dateFormat: 'dd-mm-yy',
showAnim: "slideDown",
onClose: function( selectedDate )
{
$( "#return_date" ).datepicker( "option", "minDate", selectedDate );
}
});


    function available(date)
    {
    dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
    if($.inArray(dmy, availableDatesForKhi ) != -1)
    {
    return [true, "","Available"];
    } 
    else 
    {
    return [false,"","unAvailable"];
    }
    }

how do i call & create a function

HeartDisk
  • 47
  • 1
  • 9

1 Answers1

0

You should look at this answer to constrain the dates and at jQuery UI API for the beforeShowDay method.

Community
  • 1
  • 1
developer10214
  • 1,128
  • 1
  • 11
  • 24
  • thanks, in a simple way it's working and i tried but in my scenario date will come dynamically via ajax – HeartDisk Oct 14 '13 at 10:10
  • @HeartDisk So if the value of your dropdown changes call a function which loads the array of dates into a local array which is referenced in the beforeShowDay method. This is what I whould do. – developer10214 Oct 14 '13 at 11:40