我正在尝试将动态值插入
日期选择器()方法。
我可以像这样插入一个变量:
<html>
<head>
<?php $date='2-15-2013'; ?>
<script>
var date = '<?php echo $date; ?>';
/* create an array of days which need to be disabled */
var disabledDays = [
date,
"2-21-2013",
];
/* utility functions */
function bookedDays(date) {
var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
for (i = 0; i < disabledDays.length; i++) {
if($.inArray((m+1) + '-' + d + '-' + y, disabledDays) != -1 ) {
return [false];
}
}
return [true];
}
/* create datepicker */
jQuery(document).ready(function() {
jQuery('#datepicker').datepicker({
minDate: 0,
maxDate: "+3M +10D",
dateFormat: 'dd MM, yy',
constrainInput: true,
beforeShowDay: bookedDays
});
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker" /></p>
</body>
并且日期“2-15-2013”已被正式禁用。为什么我不能再插入一串值说:
$dates = ['2-21-2013', '2-24-2013', '2-27-2013'];
$unavailable = array();
foreach($dates as $date){
array_push( $unavailable, $date);
}
$unavaildays = implode(',', $unavailable);
$string = "{$unavaildays},";
?>
<script>
var dates = '<?php echo $string; ?>';
/* create an array of days which need to be disabled */
var disabledDays = [
dates
"2-21-2013",
];
/* utility functions */
function bookedDays(date) { ...
日期:
2-21-2013,2-24-2013,2-27-2013,成为残疾人?我的值是在运行时在服务器上解析的,不是吗?