jquery autocomplete to apply to all fields that share a similar name
<p>I have a form with several rows. each row has a product column with a name starting <code>product</code>. so the names are <code>product1</code>, <code>product2</code>, <code>product3</code> etc etc.</p>

<p>I have an autocomplete script as follows:</p>

<pre><code>&lt;script type="text/javascript"&gt;
      $(function(){
        $("#product1").autocomplete({ //product is input cell to reference. autocomplete is a jquer function that is being called.
          source: "get_sku_codes",
          messages: {
          noResults: '',
          results: function() {}
      }       

        });
      });
&lt;/script&gt; 
</code></pre>

<p>This works great on input <code>product1</code> but does not work on <code>product2</code> as the script obviously references a different input.</p>

<p>How can I modify my script to be triggered when any cell starting with <code>product</code> is populated?</p>

<p><strong>UPDATE with dynamic content</strong></p>

<pre><code>&lt;script type="text/javascript"&gt;
var counter = 1;
jQuery("table.authors-list").on('change','input[name^="qty"]',function(event){
    event.preventDefault();
    counter++;
    var newRow = jQuery('&lt;tr&gt;'+
      ' &lt;td&gt;&lt;a class="deleteRow"&gt; &lt;img src="&lt;?php echo base_url() ?&gt;application/assets/images/no.jpg" /&gt;&lt;/a&gt;&lt;/td&gt;' +
      ' &lt;td&gt;&lt;input type="text" id="product' +  counter + '" name="product' +  counter + '" class="ui-input-text ui-body-c ui-corner-all ui-shadow-inset" /&gt;&lt;/td&gt;'+
      ' &lt;/tr&gt;');
    jQuery('table.authors-list').append(newRow);
});
&lt;/script&gt;
</code></pre>

<p><strong>Dipesh update</strong></p>

<pre><code>&lt;script type="text/javascript"&gt;
var counter = 1;
jQuery("table.authors-list").on('change','input[name^="qty"]',function(event){
    event.preventDefault();
    counter++;
    var newRow = jQuery('&lt;tr&gt;'+
      ' &lt;td&gt;&lt;a class="deleteRow"&gt; &lt;img src="&lt;?php echo base_url() ?&gt;application/assets/images/no.jpg" /&gt;&lt;/a&gt;&lt;/td&gt;' +
      ' &lt;td&gt;&lt;input type="text" id="product_' +  counter + '" name="product_' +  counter + '" class="ui-input-text ui-body-c ui-corner-all ui-shadow-inset" /&gt;&lt;/td&gt;' +
      ' &lt;/tr&gt;');
    jQuery('table.authors-list').append(newRow);

$('#product'+counter).autocomplete(
{
    source: "get_sku_codes",
    messages: {
        noResults: '',
        results: function() {}
    }       
});

});

jQuery("table.authors-list").on('click','.deleteRow',function(event){
 if ($(this).parents('table').find('tr').length &gt;  2) {  //get number of rows(TR's) in table 
    $(this).closest('tr').remove();
 }else{
  alert ('Form must have at least one row') // alert if only one row left in table
 }

});
&lt;/script&gt;
</code></pre>
