lundi 13 janvier 2020

Using else if to check two conditions

I have a simple form when I input '1000' in the form and submit it the result (alert) is 'Qty should not be greater than zero.' the expected result (alert) should be 'Qty should not be greater than 1000.'. I guess this is simple for you guys, but I am having a hard time correcting this.

function add_pullout_save(){
                            SYS_confirm("Do you wish Proceed?","Information will be saved to the database","warning","Yes","No",function(){
                                sweetAlertClose();  

                            var pullout_qty=$('#form_pullout_qty').val();

                            var qty=[];
                            var z=0;
                            for(var x=0;x<cnt;x++){
                                if($('#tblC_visibility'+x).val()==1){
                                    qty[z]=$('#tblC_qty'+x).val();
                                    z+=1;
                                }
                            } 


     if(pullout_qty==0 || qty==0){
        alert('Qty should not be greater than zero.');
    }else if (pullout_qty>=1000 || qty>=1000){
        alert('Qty should not be greater than 1000.');
    }
    else {
        $.ajax({
          url:URL+"index.php/pullout_request/loadPullOutRequestItemsFormTblSave",
          method:"POST",
          data:{
              qty:qty,
              pullout_qty:pullout_qty
      },
      success:function(data){
        console.log(data);
        SYS_pending_setlist();   
        setTimeout(function(){
            $("#dialog1").dialog("close");     
        },500);
    },
    error:function(err){
        console.log(err);
    }


    });
    }

    });

    }  

Aucun commentaire:

Enregistrer un commentaire