douan3414
2016-08-12 10:30
浏览 24

仅选择日期数组Jquery datepicker

I have a php array that returns a available day of the week already converted in number this 1,2,5 for (Monday, Thursday, Friday). Now i have function like this:

<script>
  $(document).ready(function() {
    $('#dataritiro').datepicker({
      minDate: 0,
      beforeShowDay: function(date) {
        var day = date.getDay();
        return [(day != 1 && day != 2)];
      }
    });
  });
</script>

But i have trouble to use it with the provided array. I need that days available is dynamically fetched from the array that I pass trough var days = <?php echo $days; ?>

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douren2831 2016-08-12 12:09
    已采纳

    You could use json_encode to translate your php array to a javascript array, then do something like @arun-p-johny suggested

    var days = (<php echo json_encode($array); ?>);
    ...
    return [days.indexOf(day) !== -1]
    
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题