a query I've been having problems with a code segment, every time I try with a different method I get a different result, and using switch is where I'm closest to getting it.
I have a page with several forms, two of them are sent in all cases and a third according to a selection in one of the fields, the data of each form is stored in different tables.
the submit should be executed in a specific order, the initial idea was this:
$(document).on('click','#grabarSalir', function(){
var cat = document.getElementById("selectCat").value;
document.getElementById('fechaalta').value = document.getElementById('date').value;
datosFacAf.submit();
datosActivoGral.submit();
if(cat == 'AUDVI' || cat == 'COM' || cat == 'HARD' || cat == 'CIEN'){
tipoElectronico.submit();
} else if (cat == 'CAMP' || cat == 'MUEB' || cat == 'LAB') {
tipoDescripcion.submit();
} else if (cat == 'VEH') {
tipoVehiculo.submit();
}
});
but for some reason that I have not been able to identify it does not save the data sent in the second submit, but if it saves the first and third, as I noticed that executing the first two there is no problem and opted to send the data of the third submit by AJAX, and it works but only for the first case group, for the second and third it fails
switch (cat) {
case "AUDVI": case "COM": case "HARD": case "CIEN":
var marca = document.getElementById('inputMarcaE').value
var modelo = document.getElementById('inputModeloE').value
var serie = document.getElementById('inputSerieE').value
var espec = document.getElementById('inputEspecificacionesE').value
$.ajax({
url: "activos_electronicoguardar.php",
method: "POST",
data:{marca:marca, modelo:modelo, serie:serie, espec:espec},
});
break;
case "CAMP": case "MUEB": case "LAB":
var marcad = document.getElementById('inputMarcaD').value
var modelod = document.getElementById('inputModeloD').value
var descd = document.getElementById('inputDescripcionD').value
var detalled = document.getElementById('inputDetalleD').value
$.ajax({
url: "activos_descripcionguardar.php",
method: "POST",
data:{marcad:marcad, modelod:modelod, descd:descd, detalled:detalled},
});
break;
case "VEH":
var nombrev = document.getElementById('inputNombreV').value
var motor = document.getElementById('inputMotor').value
var chasis = document.getElementById('inputChasis').value
var placa = document.getElementById('inputPlaca').value
var yearv = document.getElementById('inputYear').value
var marcav = document.getElementById('inputMarcaV').value
var modelov = document.getElementById('inputModeloV').value
var cilindrada = document.getElementById('inputCilindrada').value
var cappeso = document.getElementById('inputCapPeso').value
var cappas = document.getElementById('inputCapPa').value
$.ajax({
url: "activos_vehiculosguardar.php",
method: "POST",
data:{nombrev:nombrev, motor:motor, chasis:chasis, placa:placa, yearv:yearv, marcav:marcav, modelov:modelov, cilindrada:cilindrada, cappeso:cappeso, cappas:cappas},
});
break;
}
});
Suggestions?