I have two json variables needed to set a timepicker mintime and maxtime.
How can I pass the values?
Any help will be highly appreciated.
Thanks in advance.
This is the code:
var js_array_dias = <?php echo json_encode($dias_entrega);?>;
var dayValues = js_array_dias.map(function(item) {
return item.fecha_entrega
});
var fecha_viable = null;
var horario_inicio = null;
var horario_fin = null;
$(function() {
$("#datepicker").datepicker({
beforeShowDay: function(date) {
var fechas_entrega = jQuery.datepicker.formatDate('yy-mm-dd', date);
return [dayValues.indexOf(fechas_entrega) != -1]
},
onSelect: function(fecha_entrega) {
$.ajax({
type: 'POST',
url: 'seleccion_hora.php',
data: {
date: fecha_entrega
},
success: function(resp) {
if (false !== resp) {
var viable_json = resp.substr(10);
var viable = JSON.parse(viable_json);
fecha_viable = viable.fecha;
horario_inicio = viable.hora_inicio;
horario_fin = viable.hora_fin;
}
}
});
}
});
});
//Time
$('#timepicker').timepicker({
'minTime': '2:00pm',
'maxTime': '11:30pm',
'showDuration': false
});