Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 根据bootstrap datepicker中的下拉选择预先选择日期?_Php_Jquery_Bootstrap Datepicker - Fatal编程技术网

Php 根据bootstrap datepicker中的下拉选择预先选择日期?

Php 根据bootstrap datepicker中的下拉选择预先选择日期?,php,jquery,bootstrap-datepicker,Php,Jquery,Bootstrap Datepicker,任何人都知道,我如何实现以下目标: 如果有人选择“仅周末”选项,则将选择从当前月份到下个月指定日期的所有周末日期 如果有人选择“仅适用于工作日”选项,则将选择从当前月份到下个月指定日期的所有工作日日期 如果有人选择“仅星期五”选项,则将选择从当前月份到下个月指定日期的所有星期五日期 如上所述: 有人知道我从哪里开始吗 $('#dt_1').datepicker({ rtl: KTUtil.isRTL(), todayHighlight: true,

任何人都知道,我如何实现以下目标:

  • 如果有人选择“仅周末”选项,则将选择从当前月份到下个月指定日期的所有周末日期
  • 如果有人选择“仅适用于工作日”选项,则将选择从当前月份到下个月指定日期的所有工作日日期
  • 如果有人选择“仅星期五”选项,则将选择从当前月份到下个月指定日期的所有星期五日期
  • 如上所述:

    有人知道我从哪里开始吗

    $('#dt_1').datepicker({
            rtl: KTUtil.isRTL(),
            todayHighlight: true,
            templates: arrows,
            startDate: date, //disable all old dates
            setDate: date, //tomorrow's date allowed
            multidate: true,
            format: 'dd/mm/yyyy'
    
        });
    

    在stackoverflow的另一篇文章的帮助下,我找到了实现这一点的解决方案:

    PHP代码:

    //weekend.....
    $now = strtotime("now");
    $end_date = strtotime("+3 weeks");
    $weekend_array = array();
    while (date("d-m-Y", $now) != date("d-m-Y", $end_date)) {
        $day_index = date("w", $now);
        if ($day_index == 0 || $day_index == 6) {  
            // Print or store the weekends here.  
            //echo "<br>".$day_index."- Date: ".date("d-m-Y", $now);
            $weekend_array[] = date("d-m-Y", $now);
        }
        $now = strtotime(date("d-m-Y", $now) . "+1 day");
    }
    
    //friday only....               
    $now = strtotime("now");
    $end_date = strtotime("+3 weeks");
    $friday_array = array();
    while (date("d-m-Y", $now) != date("d-m-Y", $end_date)) {
        $day_index = date("w", $now);
        if ($day_index == 5) {  
            // Print or store the weekends here.  
            //echo "<br>".$day_index."- Date: ".date("d-m-Y", $now);
            $friday_array[] = date("d-m-Y", $now);
        }
        $now = strtotime(date("d-m-Y", $now) . "+1 day");
    }
    
    //weekdays......                  
    $now = strtotime("now");
    $end_date = strtotime("+3 weeks");
    $weekday_array = array();
    while (date("d-m-Y", $now) != date("d-m-Y", $end_date)) {
        $day_index = date("w", $now);
        if ($day_index >= 1 && $day_index <= 5) {  
            // Print or store the weekends here.  
            //echo "<br>".$day_index."- Date: ".date("d-m-Y", $now);
            $weekday_array[] = date("d-m-Y", $now);
        }
        $now = strtotime(date("d-m-Y", $now) . "+1 day");
    }
    
    //周末。。。。。
    $now=标准时间(“now”);
    $end_date=strottime(“+3周”);
    $weekend_array=array();
    while(日期($d-m-Y,现在)!=日期($d-m-Y,结束日期)){
    $day_index=日期(“w”,现在$now);
    如果($day_index==0 | |$day_index==6){
    //在这里打印或存储周末。
    //echo“
    ”$day_index.-Date:“.Date”($d-m-Y),$now); $weekend_array[]=日期(“d-m-Y”,$now); } $now=标准时间(日期(“d-m-Y”,$now)。“+1天”); } //只有星期五。。。。 $now=标准时间(“now”); $end_date=strottime(“+3周”); $friday_数组=数组(); while(日期($d-m-Y,现在)!=日期($d-m-Y,结束日期)){ $day_index=日期(“w”,现在$now); 如果($day_index==5){ //在这里打印或存储周末。 //echo“
    ”$day_index.-Date:“.Date”($d-m-Y),$now); $friday_array[]=日期(“d-m-Y”,现在为$now); } $now=标准时间(日期(“d-m-Y”,$now)。“+1天”); } //平日。。。。。。 $now=标准时间(“now”); $end_date=strottime(“+3周”); $weekday_array=array(); while(日期($d-m-Y,现在)!=日期($d-m-Y,结束日期)){ $day_index=日期(“w”,现在$now); 如果($day_索引>=1&&$day_索引
    $(document).ready( function () {
    
    $("#sel_dropdown").change(function() {
        $( "select option:selected" ).each(function() {
            var v = $(this).val();
            if(v == 1) {
                //weekend only....
                $('#dt_1').datepicker('setDates',[<?php 
                    $i=0;   
                    for($i=0;$i<=count($weekend_array);$i++) {
                        echo "'".$weekend_array[$i]."',";
                    }
                ?>]);
            }
            if(v == 2) {
                //Friday only.....
                $('#dt_1').datepicker('setDates',[<?php 
                    $i=0;   
                    for($i=0;$i<=count($friday_array);$i++) {
                        echo "'".$friday_array[$i]."',";
                    }
                ?>]);
            }
            if(v == 3) {
                //Weekdays only....
                $('#dt_1').datepicker('setDates',[<?php 
                    $i=0;   
                    for($i=0;$i<=count($weekday_array);$i++) {
                        echo "'".$weekday_array[$i]."',";
                    }
                ?>]);
            }
            if(v == 4) {
                //custom option....
                $('#dt_1').data('datepicker').setDate(null); 
            }
        });
    
    });
    
    });
    </script>