$(document).ready(function(){
    $("#showcredit").hide();
    // for customer
    $("#customeradd").on('change',function(){
        var customer = $(this).val();
    //    ajax for sales type
        $.ajax({
       type:'POST',
       url:'ajaxpath/vehiclecustomer.php',
       data:{customer:customer},
       success:function(a){
       //  alert(a);
        // $("#showquantity-with-color").css("display","block");
         $("#vehicleno").html(a);
         $("#emptyweight").val("");
         //alert(a);
       }
      });  
    });
    //   for customer
    // for vehicle
      $("#vehicleno").on('change',function(){
          var vehicle = $(this).val();
      //    ajax for sales type
          $.ajax({
         type:'POST',
         url:'ajaxpath/vehicleempty.php',
         data:{vehicle:vehicle},
         success:function(a){
         //  alert(a);
          // $("#showquantity-with-color").css("display","block");
           $("#emptyweight").val(a);
           //alert(a);.
         }
        });  
      
        
        });
          // for vehicle
      // for customer
      $("#productadd").on('change',function(){
        
   // ajax for unit
   var product = $("#productadd").val();
   $.ajax({
       type:'POST',
       url:'ajaxpath/secondtrans_unit.php',
       data:{product:product},
       success:function(c){
       //  alert(a);
        // $("#showquantity-with-color").css("display","block");
         $("#unitconversion").val(c);
         //alert(c);
        
        
      }
                   });
                    // ajax for unit  
    });
    //   for customer
    
  
  });
  $(document).ready(function(){
    //alert('hai');
    $("#getweightbutton").click(function(){
        var query=1;
                $.ajax({  
                     url:"ajaxpath/search1.php",  
                     method:"POST",  
                     data:{query:query},
                     success:function(data)  
                     {  
                          $('#loadweightadd').val("");  
                          $('#loadweightadd').val(data);  
                          $("#submitbut").prop("disabled",false);
						  
            //alert(a);
              $("#getweightadd").css("border","1px solid skyblue");
              $("#getweightadd").css("box-shadow","2px 1px 3px 1px skyblue");
            var empty = $("#emptyweight").val();
            var load = $("#loadweightadd").val();
            var netweight = load- empty;
            //alert(netweight);
             if(netweight < 0)
             {
                 var netweightt = empty - load;
             }
             else 
             {
                 var netweightt =   load -empty;
             }
             $("#netweightadd").val(netweightt);
             var nettwe = $("#netweightadd").val();
             var unitcon= $("#unitconversion").val();
             var finaluni = nettwe/unitcon;

             $("#netqtyadd").val((finaluni).toFixed(2));
             $("#netqtyori").val((finaluni).toFixed(2));
                

            }

           
                        });

 
                        // 
    });
    
    
    });
    $(document).ready(function(){
     $("#emptyweight").keyup(function(){
     var empty = $("#emptyweight").val();
            var load = $("#loadweightadd").val();
            var netweight = load- empty;
            //alert(netweight);
             if(netweight < 0)
             {
                 var netweightt = empty - load;
             }
             else 
             {
                 var netweightt =   load -empty;
             }
             $("#netweightadd").val(netweightt);
             var nettwe = $("#netweightadd").val();
             var unitcon= $("#unitconversion").val();
             var finaluni = nettwe/unitcon;

             $("#netqtyadd").val((finaluni).toFixed(2));
             $("#netqtyori").val((finaluni).toFixed(2));
    });
    });
    $(document).ready(function(){
      $("#loadweightadd").keyup(function(){
      var empty = $("#emptyweight").val();
             var load = $("#loadweightadd").val();
             var netweight = load- empty;
             //alert(netweight);
              if(netweight < 0)
              {
                  var netweightt = empty - load;
              }
              else 
              {
                  var netweightt =   load -empty;
              }
              $("#netweightadd").val(netweightt);
              var nettwe = $("#netweightadd").val();
              var unitcon= $("#unitconversion").val();
              var finaluni = nettwe/unitcon;
 
              $("#netqtyadd").val((finaluni).toFixed(2));
              $("#netqtyori").val((finaluni).toFixed(2));
     });
     });
	 