naga raj naga raj - 14 days ago 5
jQuery Question

What going wrong with my js inarray()

var element = "";
var aval_qty = "";
var all_qtys = [];
var chk = "";
$.each(data.response.tot_avl, function (a,b){
aval_qty = '.qty'+b.id_itm;
$(aval_qty).each(function(i, obj) {
$(this).children().eq(0).val(b.qtys);
});
all_qtys.push(parseInt(b.qtys));
});
if($.inArray(parseInt(0),all_qtys)){
$('.btn-primary').attr('disabled',true);
}else{
$('.btn-primary').attr('disabled',false);
}


let me say array
(all_qtys)
has values of
0,10,20
.

array has 0 value in it trying to disable submit button..is some thing wrong with array push

Ex; array has item quantity's if any item quantity is zero need not to allow user to submit

Answer
if($.inArray(parseInt(0),all_qtys)!== 0){ 
$('.btn-primary').attr('disabled',false); 
}else{  
    $('.btn-primary').attr('disabled',true);
}
Comments