Closed edgrod01 closed 6 years ago
hi, please help
Did you try json_encode
? A string is not an object. You can check this in JavaScript with typeof
.
hello, thank for your help, excuseme for my english im colombian. Also i new programming :)
these are the dates in my bd
CREATE TABLE `citprogagenda` (
`ideCitProgAgenda` int(11) NOT NULL COMMENT 'LLAVE PRIMARIA',
`ideGenHisEspecialidad` int(11) NOT NULL COMMENT 'IDE ESPECIALIDAD',
`ideGenPerEmpleado` int(11) NOT NULL COMMENT 'ID MÉDICO',
`ideGenUbicacion` int(11) NOT NULL COMMENT 'ID CONSULTORIO',
`fecInicio` date NOT NULL COMMENT 'FECHA INICIO DE AGENDA',
`fecFinal` date NOT NULL COMMENT 'FECHA FIN DE AGENDA',
`fecInactiva` text NOT NULL COMMENT 'FECHAS INACTIVAS',
`ideGenIntervalo` int(11) NOT NULL COMMENT 'IDE INTERVALO',
`indActivo` int(1) NOT NULL DEFAULT '1' COMMENT 'INDICADOR DE ACTIVO'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
----------------------
INSERT INTO `citprogagenda` (`ideCitProgAgenda`, `ideGenHisEspecialidad`, `ideGenPerEmpleado`, `ideGenUbicacion`, `fecInicio`, `fecFinal`, `fecInactiva`, `ideGenIntervalo`, `indActivo`) VALUES
(7, 1, 3, 1, '2018-02-22', '2018-02-28', '', 48, 1),
(8, 1, 3, 1, '2018-03-22', '2018-03-28', '', 48, 1);
im trayin send the values from php to JS, this is te code in php
case 'agenda':
$rpta= $citAgenda->agenda($ideGenPerEmpleado, $ideGenUbicacion);
$fecha= array();
while($datos=$rpta->fetch_object())
{
array_push($fecha,'{from: ['.$datos->fecInicio.'], to: ['.$datos->fecFinal.']}');
}
echo json_encode($fecha);
break;
-------------- and here recieve in JS to send to pickdate
$("#ideGenUbicacion").on("change", function(e)
{
$.post("../ajax/citAgenda.php?op=agenda",{ideGenPerEmpleado: $("#ideGenPerEmpleado").val(), ideGenUbicacion: $("#ideGenUbicacion").val() }, function(data, status)
{
console.log(data);
console.log(data.length);
data= data.replace(/[-]/gi,',');
data = JSON.parse(data);
console.log(data);
var inputpick = $('#fecha').pickadate();
var pick = inputpick.pickadate('picker');
console.log (pick.set('disable', [data] ));
});
});
-------------in the console show this in the constructor
item:
clear:null
disable:Array(1)
0:(2) ["{from: [2018,02,22], to: [2018,02,28]}", "{from: [2018,03,22], to: [2018,03,28]}"]
length:1
hi Daniel, could you help me, thanks
hia Daniel, after i trying, i get it, thanks for you help, look:
$.post("../ajax/citAgenda.php?op=agenda",{ideGenPerEmpleado: $("#ideGenPerEmpleado").val(), ideGenUbicacion: $("#ideGenUbicacion").val() }, function(data, status) {
// console.log(data);
// console.log(data.length);
data= data.replace(/[-]/gi,',');
data= data.replace(/[""]/gi,'');
// console.log(eval(data));
// var inputpick = $('#fecha').pickadate();
// var pick = inputpick.pickadate('picker');
// console.log(pick.set('disable', eval(data)));
console.log( $('#fecha').pickadate({
today: '',
clear: '',
close: '',
format: 'yyyy-mm-dd',
formatSubmit: 'yyyy-mm-dd',
weekdaysShort: ['Dom', 'Lun', 'Mar', 'Mie' ,'Jue', 'Vie', 'Sab'],
monthsShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
showMonthsShort: true,
selectMonths: true,
selectYears: true,
disable: eval(data)
}));
});
eval
should be normally avoided. So this is solved for you?
hmmm, thanks for answer, really i new programming, don't know why avoid eval, could you explain me... thank
and its rigth, with just use it, solved my problem, its looking disabled the dates.
But now i get other problem, how can i do for january by the number 1 no 0
thanks
0 is January in JS. Just substract 1 from your month string.
eval
is a security problem.
thanks for your help, i solved the problem, in php i rest 1 to the month
thanks
Okay, thanks for the feedback.
hi! im trying to send the value for disable the dates by a variable, but no excecute nothing, i take the value and paste, this excecute fine. how can i do for send the variable. ej
Thanks for your help