JavaScript - jQuery - PHP: dynamically display specific time in my datetimepicker from database
I have a jQuery datetimepicker using the xdsoft plugin . I only want to display specific hours / times that have 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 that I cannot use the technique to get time values ββfrom my database and integrate it into my jQuery. This is what I want:
allowTimes:[my time values in my database],
PLEASE HELP ME: '(
Thank.
+3
queen yhen
source
to share
1 answer
You can bind the datepick in ajax callback:
$.ajax({
method: 'GET',
url: 'gettimes.php'
}).done(function(response){
$('#datetimepicker1').datetimepicker({
formatDate:'Y/MMM/d',
allowTimes:[
response //JSON STRING with allowed Times
]
});
});
+1
Daan
source
to share