I have implementation aj query date and time picker into a website. 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:
<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)
http://xdsoft.net/jqplugins/datetimepicker/
it has a disabledDates
option which can be used the same way as the example of the post mentioned. 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. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.