I have a form with 2 dependent comboboxes: Combo A and Combo B:
When I make a new record there is no problem I select A and it shows in B what belongs to it, I select it and it registers in my DB.
My drawback is when I already want to edit the record, I load the data in that form (including Combo A with their data and it auto selects its value that is) but when I also want to load it in combo B depends on what is charged in Combo A and autoseleccionarlo the value that was passed, but it does not work
I have it like this: Article (I get the data of the record to edit)
function getArticulo(pIdArticulo){
getSeccion('cboSeccionArticulo')
$.ajax({
url:'articulo/'+pIdArticulo+'/edit',
type: 'GET',
dataType:'JSON',
success:function(data){
getCategoriaxSeccion('cboCategoriaArticulo',data.seccion_articulo)
$('#cboSeccionArticulo').val(data.seccion_articulo);
$('#cboCategoriaArticulo').val(data.categoria_articulo);
}
})}
function getSeccion(pContenedor){
$.ajax({
url: 'seccion/',
type: 'GET',
dataType: 'JSON',
success: function(response){
$('#'+pContenedor).empty()
$('#'+pContenedor).append('<option value="">'+'[ Selecciona ]'+'</option>')
for (var i =0; i<response.length; i++) {
$('#'+pContenedor).append('<option value="'+response[i].id_seccion+'">'+response[i].detalle_seccion+'</option>')
}
}
})}
function getSeccion(pContenedor){
$.ajax({
url: 'seccion/',
type: 'GET',
dataType: 'JSON',
success: function(response){
$('#'+pContenedor).empty()
$('#'+pContenedor).append('<option value="">'+'[ Selecciona ]'+'</option>')
for (var i =0; i<response.length; i++) {
$('#'+pContenedor).append('<option value="'+response[i].id_seccion+'">'+response[i].detalle_seccion+'</option>')
}
}
})
}
I understand that the call is asynchronous, but does anyone know any way to do it or is there some property that I am not considering?