I been trying to find a way of how autocomplete one input at a time , But the struggle is that the input are created from a select * from a table on a db. . And when typing in one input and selecting the result the other input changes as well.
php
 while ($row = $resultado->fetch_assoc()) {
                         echo "<tr>
                           <td><input type='text' name='name[]' class='name' 
                           value='".$fila["name"]."'/> 
                           </td>
                       }
js
<script type='text/javascript'>
     $(function() {
            $('.name').autocomplete({
                source: '../ajax/pro.php',
                minLength: 1,
                select: function(event, ui) {
                    event.preventDefault();
                    $('.name').val(ui.item.name);
                    $('#name').val(ui.item.name);
                  
                   
                 }
            });
        });
   </script>
Advertisement
Answer
You are changing values of all elemnts which contain class named name
$('.name').val(ui.item.name);
That’s not the right way to changing value you should use
$(this).val(ui.item.name);
so $(this) will change only that inputs value which was selected