[英]How to disable a specific date and time in a JQuery date time picker
I have implementation aj query date and time picker into a website. 我已将aj查询日期和时间选择器实施到网站中。 The picker is working and when i select a date and time it saves to a database. 选择器正在工作,当我选择一个日期和时间时,它将保存到数据库。 what i can not figure out how to do is disable any date and times which are in the database, so that no one can select a time on a date which has previously been selected. 我不知道该怎么做是禁用数据库中的任何日期和时间,以便没有人可以选择以前选择的日期上的时间。 This is my code for the jquery picker, searching the database for the valus isnt a problem im just not sure how to set it in the picker itself: 这是我的jquery选择器的代码,在数据库中搜索值不是一个问题,只是不确定如何在选择器本身中设置它:
<script type="text/javascript">
$(function(){
$('*[name=date2]').appendDtpicker({"inline": true,
"allowWdays": [1, 2, 3, 4, 5], // 0: Sun, 1: Mon, 2: Tue, 3: Wed, 4: Thr, 5: Fri, 6: Sat
"futureOnly": true,
"autodateOnStart": false
});
$('#btn_input').on('click', function(){
var input = $('*[name=date2]').handleDtpicker('getDate');
var select = document.getElementById("doctor").value;
var select1 = document.getElementById("patient").value;
console.log(input);
$.post( "backend2.php", {
'input':input,
'select':select,
'select1':select1
}).done(function( data ) {
alert( "You have selected" + data );
});
});
});
</script>
If you read the documentation of datetimepicker (if this is the plugin you are using) 如果您阅读了datetimepicker的文档(如果您使用的是插件)
http://xdsoft.net/jqplugins/datetimepicker/ http://xdsoft.net/jqplugins/datetimepicker/
it has a disabledDates
option which can be used the same way as the example of the post mentioned. 它有一个disabledDates
选项,可以使用与上述帖子示例相同的方式使用。 Build the array of dates with your scripting language. 使用脚本语言构建日期数组。
From the docs: 从文档:
{disabledDates: ['01.01.2014','02.01.2014','03.01.2014','04.01.2014','05.01.2014','06.01.2014'], formatDate:'d.m.Y'}
From this post: 从这篇文章:
Jquery UI datepicker. jQuery UI日期选择器。 Disable array of Dates 禁用日期数组
It explains how to disable dates. 它说明了如何禁用日期。 What you can do is build the array of disabled dates with a query from the database and echoing it in the javascript with whatever scripting language you are using. 您可以做的是使用数据库中的查询来构建禁用日期的数组,然后使用您使用的任何脚本语言在javascript中回显它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.