Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8934903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:52:50+00:00 2026-06-15T09:52:50+00:00

I have an issue trying to apply jQuery AutoComplete to multiple rows in a

  • 0

I have an issue trying to apply jQuery AutoComplete to multiple rows in a table when using jQuery clone. The AutoComplete works on the first row but fails to work when additional rows are added to the table. So far, I have the following:

HTML Table:

    <table class="table" cellspacing="0" id="myTable">
      <tr> 
        <th width="40%">Item</th> 
        <th width="60%">Description</th> 
      </tr> 
      <tr>
        <td>input name="product_title" id="product_title" type="text"><td> 
        <td><textarea name="product_description" id="product_description"></textarea></td> 
      </tr> 
    </table>
   <input type="button" value="Add Row" onclick="javascript:addRow()">

Clone Script:

function addRow(){
  $('#myTable tr:last').clone(true).insertAfter('#myTable tr:last');
  $('#myTable tr:last input').val("");
  $('#myTable tr:last input:first').focus();        
}

AutoComplete script:

$().ready(function() {
  $("#product_title").autocomplete(products, {
    width: 380,
    matchContains: "word",
    formatItem: function(row) {
      return row.title;
    }
  });   
  $('#product_title').result(function(event, data) {
  $('#product_description').val(data.description);
  });   
});

The data for the autocomplete is pulled from a simple MySQL query which defines the product title and description.

At the moment, the add new row works fine and so does the AutoComplete for the first row of the table, however it fails to work on any additional rows that are added. Even if I add a second row manually to the HTML table, the AutoComplete doesn’t work on this either.

Does anybody know if there is an (easy) way to modify the above code to make this work? I’m a novice when it comes to jQuery so the more details, the better.

Thanks in advance!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:52:51+00:00Added an answer on June 15, 2026 at 9:52 am

    This is a common issue using plugins on dynamically added elements. It usually requires calling the plugin on the new elements after they are inserted in the DOM. Instead of duplicating the same code for the initial page load elements and new elements, you can usually create a simple helper function that uses a parent element as the main reference and searches only within that element for the elements to apply the plugin to.

    Important: You are repeating ID’s when you clone new rows and ID’s must be unique in a page by definition. The following code changes your ID’s to class instead and you will need to do same in your markup.

    var $table;
    $(function() {
         $table=$('#myTable'); 
         var $existRow=$table.find('tr').eq(1);
          /* bind to existing elements on page load*/
          bindAutoComplete($existRow);
    });
    
    function addRow(){
        var $row=$table.find('tr:last').clone(true);
        var $input=$row.find('input').val("");
        $table.append($row);
        bindAutoComplete($row );
        $input.focus();
    
    }
    
    
    function bindAutoComplete($row ){
        /* use row as main element to save traversing back up from input*/
        $row.find(".product_title").autocomplete(products, {
            width: 380,
            matchContains: "word",
            formatItem: function(row) {
                return row.title;
            }
        });
        $row.find('.product_title').result(function(event, data) {
            $row.find('.product_description').val(data.description);
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some strange issue when trying to apply a conversion from HSI to
I have this issue trying to get all the text nodes in an HTML
I have ran into an interesting issue while trying to create a more usable
I have an issue with psql. I am trying to select the records from
I have an issue where in, I am trying to add copyrights message in
I have an issue with a for loop in java. I'm trying to do
can anyone help? I have an issue with linq2sql and trying to Attach (update)
I have an encoding issue in perl when trying to pull back global addresses
The issue I am trying to solve is that I have a folder with
I’m trying to issue web requests asynchronously. I have my code working fine except

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.