亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在日期選擇器中禁用選定日期的日期

在日期選擇器中禁用選定日期的日期

PHP
胡子哥哥 2023-03-04 18:01:13
我的 Laravel 應用程序中有一個在線預約表格,其中包含一些歸檔Select Doctor和datepicker.假設醫生A將在周六、周一和周三到診所。醫生B將在周日、周二、周四有空。A因此,當任何患者從現場選擇醫生時Select Doctor,日歷中所有星期六、星期一和星期三的日期都將被激活datepicker,其他日期將被停用。我已經停用了一些選定的datepicker日歷日期。但不能禁用datepicker.網頁格式<input class="form-control" id="appointment_datepicker" name="appointment_datepicker" type="text" placeholder="Select Date" value="{{ $user->appointment_datepicker or old('appointment_datepicker') }}">阿賈克斯    $.ajax({      url:"{{ url('/filter_available_date') }}",      type: 'GET',      data: {_token :token, branch_id_appointment : branch_id_appointment, doctor_id_appointment : doctor_id_appointment},      success:function(msg){        $('#appointment_datepicker').datepicker('option', 'beforeShowDay', function(date){                var day = jQuery.datepicker.formatDate('yy-mm-dd', date);                return [ msg.indexOf(day) == -1 ] //here msg is the Array of selected Dates which are activated in the datepicker calendar            });                        }});路線Route::get('/filter_available_date','frontendAppointmentController@filter_available_date');控制器public function filter_available_date(Request $request){    $branch_id = $request->branch_id_appointment;    $doctor_id = $request->doctor_id_appointment;        $query =  DB::table('service_doctors');    $query->select('doctor_id','inactive_dates_in_this_month');        if($branch_id != '0')        $query->where('branch_id','=', $branch_id);    if($doctor_id != NULL)        $query->where('doctor_id','=', $doctor_id);    $result_time = $query->get();        $result = [$result_time[0]->inactive_dates_in_this_month];        $final_result= explode(',',$result[0]);        return $final_result;}日歷如何解決這個問題?有人幫忙嗎?提前致謝。
查看完整描述

2 回答

?
呼喚遠方

TA貢獻1856條經驗 獲得超11個贊

乍一看,這似乎是日期不匹配的問題。如果您使用下面的示例,您可以看到來自 API 的數據應該是什么樣子。


var msg = ["2020-05-11"];

$('#appointment_datepicker').datepicker({

  beforeShowDay: function(date) {

    var day = jQuery.datepicker.formatDate('yy-mm-dd', date);

    return [msg.indexOf(day) == -1]

  }

});

<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.0/themes/smoothness/jquery-ui.css" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js" integrity="sha256-eGE6blurk5sHj+rmkfsGYeKyZx3M4bG+ZlFyA7Kns7E=" crossorigin="anonymous"></script>

<input class="form-control" id="appointment_datepicker" name="appointment_datepicker" type="text" placeholder="Select Date">


查看完整回答
反對 回復 2023-03-04
?
哆啦的時光機

TA貢獻1779條經驗 獲得超6個贊

這里每天都有一個固定號碼,例如


Sunday = 0

Monday = 1

Tuesday = 2

Wednesday = 3

Thursday = 4

Friday = 5

Saturday = 6 

所以Array一天的數字(例如:var arr = [1, 2, 3];)從控制器返回,那一天將在datepicker.


只需在 Ajax 中更改以下代碼


阿賈克斯


var arr = [1, 2, 3] //these are the array of days numbers return from controller


$('#appointment_datepicker').datepicker('option', 'beforeShowDay', function(date){

            var day = date.getDay();

            return [(arr.indexOf(day) != -1)];

    });

所以只在這里Monday,Tuesday并將Wednesday在日歷中激活datepicker。

http://img1.sycdn.imooc.com//640317490001e38002970289.jpg

查看完整回答
反對 回復 2023-03-04
  • 2 回答
  • 0 關注
  • 211 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號