I have this onClick in js
$("#TblAsigRol > tbody").on('click', '.c_BtnGurdarRol', function(event)
{
var nombre= event.target.id;
var toRemove = 'btnguardar';
var id= nombre.replace(toRemove,'');
//se toma la c�dula
var idempleado = 'documen_ident' + '' + id;
var doc= $("#" + idempleado).val();
//Se toma el valor del rol
var idrol = 'rol' + '' + id;
var rolemp= $("#" + idrol).val();
console.log(cdc2);
//alert(doc + " " + rolemp);
procesarDatos("ModificarRol", {idoc:doc, rol:rolemp, obj:cdc2 });
});
The problem I have is that the object cdc2 which comes with a value of 0: "CCC0" . then when passing the values in a function in php which is
function ModificarRol($datos)
{
$FechaActual= fechaActual();
$sql = 'UPDATE 'empleados' SET idrol=\''. $datos['rol']. '\' , UsuarioModificion=\''. $_SESSION['NombreUsario']. '\' , FechaModificacion=\''. $FechaActual. '\' WHERE docum_ident = \''.$datos['idoc'] . '\';';
$result = execute_query($sql);
foreach ($datos['obj'] as $row ) {
$sql = 'INSERT INTO 'detalle_usuarioxcc' ('docum_ident', 'CentroCosto') VALUES ("'.$datos['idoc'].'", "'.$row['obj'].'")';
$result = execute_query($sql);
}
echo json_encode($result);
}
At the moment of inserting into obj in mysql, only the first character is inserted, that is, the table is CentroCosto = C