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 8252603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:36:15+00:00 2026-06-08T00:36:15+00:00

AutoComplete works correctly for the static field, but it doesn’t work for dynamic fields.

  • 0

AutoComplete works correctly for the static field, but it doesn’t work for dynamic fields.

I’ve tried .live() method for I could not get it to work correctly.

Here is my HTML:

<table>
    <tr class="selectmatprimas">
        <td>
            <input type="text" class="selectmatprima" />
            <input type="text" name="matprimas[]" />
        </td>
    </tr>
    <tr class="clone" style="display:none;">
        <td>
            <input type="text" class="selectmatprima" />
            <input type="text" name="matprimas[]" />
        </td>
    </tr>
</table>
<input type="button" value="addmore" id="addmore" />

​
Here is my JS:

var src = [
    {
        "label": "Mat\u00e9ria Prima 1",
        "value": "1"
    },
    {
        "label": "Mat\u00e9ria Prima 2",
        "value": "2"
    }
];

$("input.selectmatprima").autocomplete({
    source: src,
    select: function (event, ui) {
        event.preventDefault();
        this.value = ui.item.label;
        $(this).next().val(ui.item.value);
    },
    focus: function (event, ui) {
        event.preventDefault();
        this.value = ui.item.label;
        $(this).next().val(ui.item.value);
    }
});

$("input#addmore").click(function(){
    var a = $('tr.clone').html();
    var b = $('tr.selectmatprimas:last');
    b.after("<tr class='selectmatprimas'>"+a+"</tr>");
});

Online DEMO

As you can see, when I click the addmore button, the autocomplete doesn’t work on the new fields…

  • 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-08T00:36:16+00:00Added an answer on June 8, 2026 at 12:36 am

    I’ve only scratched the surface with your code but here’s a working version

    The key is jQuery’s on() function which you can read about here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This works in firefox but doesn't do anything in IE: $(#_results).autocomplete({ source: data, minLength:
Most of the time the autocomplete feature in Vim works nicely for me, but
I am using AutoComplete widget. It works fine for two characters search but doesen't
using jquery ui 1.8 trying autocomplete Everything works apart from that the ui-menu isn't
Does anyone know if theres a jquery autocomplete library that works similar to the
Hello, I’ve written a script for autocomplete like Facebook; it works well on a
I'm having trouble getting Indextank's AutoComplete feature to work in my Rails application. I'm
I have a simple autocomplete field that spits out a bunch of suggested words
I'm trying to build an AutoComplete DropDown List that will work on a Mobile
I am looking into the Google Places Autocompleter . It works perfectly, I tried

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.