I have been battling with this jquery mobile datepicker for 2 days now!!
这是我的代码,我正在检索布尔值设置为 1 的日期(禁用天数),我无法让 datepicker 禁用它们!请帮忙..我正在尝试从我的mysql查询中将一个带有json的数组返回给datepicker
booked_dates.php
内容:
<?php
require_once("connect.php");
mysql_select_db("eyecandysf");
$booked_date = mysql_query("SELECT date, FROM date_time WHERE booking_status !=0 ");
while ($result = mysql_fetch_array($booked_date)){
$dates[] = $result['date'];
}
echo json_encode($dates);
?>
main.php
内容:
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" />
<link rel="stylesheet" type="text/css" href="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.min.css" />
<link rel="stylesheet" href="http://mobile-bydesign.com/mmc/mobile/3.0.4/themes/eyecandysf22.css" />
<link href="http://mobile-bydesign.com/mmc/mobile/3.0.4/photoswipe.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>
<script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.core.min.js"></script>
<script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.mode.calbox.min.js"></script>
<script type="text/javascript" src="datepicker_mobile.js"></script>
<script type="text/javascript">
$.getJSON('booked_dates.php', function(data) {
var bookedDays = data;
});
function isAvailable(date){
var dateAsString = date.getFullYear().toString() + "-" + (date.getMonth()+1).toString() + "-" + date.getDate();
var result = $.inArray( dateAsString, bookedDays ) ==-1 ? [true] : [false];
return result
}
$('#date').datepicker({minDate: 0, maxDate: "+2M", beforeShowDay: isAvailable});
</script>
<style>
.ui-select .ui-btn select{
font-size: 50px;
}
</style>
</head>
<body>
<form data-ajax="false" id="date" action="time.php" method="post">
<div id="dateDiv" data-role="fieldcontain">
<label for="mydate" class="ui-hidden-accessible">date </label>
<input name="date" type="date" id="date" data-theme="b" data-role="datebox" value="" placeholder="date"
data-options='{"mode": "calbox", "afterToday": true,"blackDays": [1], "maxDays": 65}'/>
</div>
<input type="submit" value="select time" name="submit" />
</form>
</body>
</html>