<?php 
 require_once "labClass.php";
 $con = new labClass();
  ?>
 <div class="container mt-3" style="width:100%;">
<div id="disR"></div>
 <div  class="mt-4 p-5 bg-white text-dark rounded">
    <h6>Create stock for:</h6>
   <div class="row">
    
     <div class="col"> 
      <label for="cname" class="form-label">Specify agent: Name:</label>
      <input class="form-control" list="cnames" name="cname" id="cname" onchange="processData();">
      <datalist id="cnames">
      <?php
      $Q= $con->getAgListBaN();
      if ($Q->rowCount()>0) {
      $lb=
      $Q->fetchAll();
      foreach ($lb as $key => $l) {
      
      ?>
      <option value="<?php echo  $l["cname"];?>">  
             <?php
           }
           }
      ?>
      </datalist>
   
    </div>
    <div class="col">
      <sup id="ph" style="display:none;"></sup>
    </div>
    <div class="col">
     <label for="cname" class="form-label">Search/Sort by: Name:</label> 
      <input type="text" onkeyup ="submision()" class="form-control" id="tname" style="width:100%; height:40px; border-radius:12px;" placeholder="Test name" name="tname" required>  
    </div>
</div> 
 
 <div id="dispR">
   
 <?php
   //require_once "labToolkitListOp.php";
   ?>
   
 </div>
 
  
   
      

 

 <script>
function processData(){ 
var ecc=0; 
var cname =document.getElementById('cname').value; 
$.trim(cname);  
  //FIRST NAME VALIDATION
  
if(cname==""){ 

         ecc++;
         alert('Item customer is required!..');
             }
 
  
    if(ecc==0)
    { 
        $.post("pharmGetAgBN.php",
          {cname:cname},
          function(data){
      $('#ph').html(data).show();

    });
    }
 
} 
  function submision(){
    
    var searchValue=$('#tname').val();

    
 ;
    $('#dispR').empty();
    $.post('pharmNwAgntSSearch.php',{searchValue:searchValue},function(data){
      $('#dispR').html(data);

    });
  }
 
 
</script>
 