I'm doing a program for a cerezaria that sends empty barrels to fill.
in the stock form you enter the type of beer and a barrel number. Then I get a JSON from the barrels table through an AJAX request. And I want to check if the "active" field of the barrel table of that idbarril is in 1, so if it is empty it is possible to fill it: When loading the stock form I have:
var accion= "barriles";
$.ajax({
type: "POST",
url: "../gestionweb/views/modules/stock/procesostock.php",
data:{"accion":accion},
error: function(){
alert("error petición ajax");
},
success:function(data)
{
barriles=data;
if (!data.length===0){
alert("no hay envases vacios");
}
}
});
function compruebaBarril(){
for (var i = 0; i < barriles.length; i++) {
if (barriles[i].idbarril===barril){
}
}}
The above function I want to call by clicking confirm, if it is available the barrel continued the process. But I do not know how to do ... thank you