php - Datepicker Unavailable dates (data retrieved from database) -
i'm trying dates database , put them in array stored in json.
main.php
$('#datepicker').focus(function(){ $.ajax({ url: 'getdates.php', data: "artist_name="+$('#name').html(), datatype: 'json', success: function(data) { } }); })
getdates.php
$fullname = $_get['artist_name']; $result = mysql_query("select .... .... ... ='$fullname'") $arraydates = array(); while($details = mysql_fetch_assoc($result)) { array_push($arraydates, $details['event_date']); } echo json_encode($arraydates);
i've managed put dates selected artist in "arraydates".
i found on google:
var unavailabledates = ["21-8-2013"]; function unavailable(date) { dmy = date.getdate() + "-" + (date.getmonth() + 1) + "-" + date.getfullyear(); if ($.inarray(dmy, unavailabledates) == -1) { return [true, ""]; } else { return [false, "", "unavailable"]; } }
that's fine. i'm trying results array (within getdates.php) , use them in "main.php". want use data above "unavailabledates" array. (and thus, disable specific dates within jquery date picker).
instead of having "unavailabledates", have "arraydates". don't know how can use array inside "unavailable" function.
i'm not json, it's first time used json. please me that?
you can use jquery:
//... success: function(data){ var arraylength=data.length; for(var i=0;i<arraylength;i++){ if(unavailable(data[i]){ //your code here } } } //...
Comments
Post a Comment