dtg7662 2015-05-04 09:28
浏览 97
已采纳

JavaScript - jQuery - PHP:在数据库中的datetimepicker中动态显示特定时间

I have a jQuery datetimepicker using xdsoft plugin. I want to display only specific hours/time that has been stored in my database(using php).

Example if I have values in my database:

'12:00', '13:00', '15:00', 
'17:00', '17:05', '17:20', '19:00', '20:00'

And this is my jQuery for datetimepicker:

$('#datetimepicker1').datetimepicker({
  formatDate:'Y/MMM/d',
  allowTimes:[
    '12:00', '13:00', '15:00', 
    '17:00', '17:05', '17:20', '19:00', '20:00'
  ],
});

My problem is I can't used a technique to get the time values from my database and integrate it to my jQuery. This is what I want:

allowTimes:[my time values in my database],

PLEASE HELP ME :'(

Thanks.,

  • 写回答

1条回答 默认 最新

  • douche1936 2015-05-04 09:32
    关注

    You can wrap the datepicker in an ajax success callback:

    $.ajax({
      method: 'GET',
      url: 'gettimes.php'
    }).done(function(response){
      $('#datetimepicker1').datetimepicker({
      formatDate:'Y/MMM/d',
      allowTimes:[
         response //JSON STRING with allowed Times
       ]
      });
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器