how to access database from within beforeShowDay : datepicker

how to access database from within beforeShowDay : datepicker

I am trying to access the booked dates from database inside beforeShowDay function. The problem is that

1) i am not able to return "return [true,"",""];" inside daystomark.
2) if i write return statements, they are executing before the database access. 

Can anyone help me?


  1. $('#calendar').datepicker({ ..... beforeShowDay : daystomark }); function daystomark(date) { var da = date.toString(); var subdate = da.substring(4,15); datesbooked = "" ; bookeddates(function(datesbooked) { var markeddates = datesbooked.split(","); if($.inArray(subdate,markeddates) == -1 ) return [true,'zeroday',""]; else return [true,'markedDay',""]; }); } function bookeddates(callback) { var db1 = openDatabase("Test1","1.0","Test1",65535); db1.transaction(function(transaction) { var sql = "SELECT * FROM customers"; transaction.executeSql(sql,undefined,function(transaction,result) { var mark = ""; for(var i=0;i<result.rows.length;i++) { var row = result.rows.item(i); /* retrieving the dates */ mark += row.dinfo + ","; } callback(mark); }); }); }