I have certain date saved in my MySQL , and i want to enable those dates in my jQuery datepicker and disable rest date .

Here is my Try :

my date after being fetched from mysql is :-

1). From 07-07-2014 to 15-07-2014

2). 23-08-2014

3). From 25-08-2014 to 26-08-2014

And to store it in jQuery datepicker , Below is javascipt code.

<script type="text/javascript"> var availableDates = [9,14,15]; //desired Days var availableMonth = [1,5,7]; //desired Month var availableYear = [2014,2015]; //desired Year function available(date) { dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear(); if (jQuery.inArray(date.getDate(), availableDates) != -1 && $.inArray((date.getMonth()+1), availableMonth) != -1 && $.inArray(date.getFullYear(), availableYear) != -1) { return [true, "","Available"]; } else { return [false,"","unAvailable"]; } } jQuery('#datepicker').datepicker({ beforeShowDay: available }); </script>

Current Script is enabling only above dates in every month, but i want it to be some dynamic date for every month. For that i tried to create below object, but am not sure how to implement it.

var availableTime = { '2014' : { '07' : ['07', '08', '09', '10'], '08' : ['01', '02', '05'] }, '2015' : { '02' : ['11', '18', '19', '21'], '03' : ['21', '22', '25'] } }; jQuery(document).ready(function() { for(var j in obj ) { for(var p in obj[j] ) { for(var i = 0; i < obj[j][p].length; i++ ) { console.log(obj[j][p][i]); } } } });

How can i implement, them ?

datepicker in question is from here : http://api.jqueryui.com/datepicker/

Thanks