I explain what I have tried to do, I have created 2 select dependents, one is called type of person (Natural Person and Legal Entity) and the other company , select the type of person, the next select (company) will load the corresponding data. Until then I'm fine. Then when I select a company I need to upload data from the company table, the detail is that at the same time I must load data from another table in which is the ID of the company, in this case, business turn. / p>
$('#empresa').on('change', function(e){
console.log(e);
var empresa_id = e.target.value;
//alert(empresa_id);
$.get('select_empresa?empresa_id=' + empresa_id,function(data) {
console.log(data);
$('#empresa_nombre').empty();
$('#empresa_ruc').empty();
$('#empresa_mail').empty();
$('#empresa_tel').empty();
$('#empresa_dir').empty();
$('#empresa_giro').empty();
document.getElementById('infoempresa').style.display = 'block';
$.each(data, function(datos_empresa, empObj){
$('#empresa_nombre').val(empObj.companyname_cny);
$('#empresa_ruc').val(empObj.ruc_cny);
$('#empresa_mail').val(empObj.email_cny);
$('#empresa_dir').val(empObj.address_cny);
$('#empresa_tel').val(empObj.phone_cny);
//$('#empresa_giro').val("Giro de Negocio");
})
});
});
In this script I send the data to the form that contains the company data, the problem is with the field Business Turning
function datos_empresa(Request $request)
{
$empresa_id = Input::get('empresa_id');
$empresa = Empresa::where('id','=',$empresa_id)->get();
$giro = negocio::where('empresa_id','=',$empresa_id)->get();
//dd($giro);
return Response::json(['empresa'=>$empresa, 'giro'=>$giro]);
}
This is my function of the controller to load the data, the detail is that it does not show me anything.