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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:44:22+00:00 2026-06-17T05:44:22+00:00

My case is simple. I have a container div. In it I have an

  • 0

My case is simple. I have a container div. In it I have an input box called tagName. To this I have attached the autocomplete plugin (jquery.autocomplete.js). When the drop-down occurs, and either the keyboard or the mouse is used to select the choice of country, I capture the onSelect event and declare

    $('#tagName').autocomplete({
        lookup: countriesArray,
        onSelect: function () {
            $(this).parent().append($('<input/>', {
                value: '',
                type: 'text',
                name: 'paramName1',
                id: 'paramName1'
            }));
            $('#paramName1').focus();

Within the onSelect, I can apply autocomplete, but if I end this function, and then say

$(‘#paramName1’).autocomplete({
lookup: citiesArray,… etc

then autocomplete is not applied to paramName1.

I feel like this method of creating input textboxes is very inefficient. How can I create an input box and assign it an id dynamically? Additionally, the autocomplete plugin must work on the newly created input box. Thanks for looking.

PS: I imagine after that, adding a delete button on hover/focus, and extra functionality will be easier. This is my first jQuery project.

  • 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-17T05:44:23+00:00Added an answer on June 17, 2026 at 5:44 am

    You have to call $('#paramName1').autocomplete({ lookup: citiesArray,... etc. inside the onSelect function. The reason why it dont work outside is because the element does not exist yet. So, the autocomplete cannot be applied.

    And if you want the id dynamically, you can use a variable to set it.

    Something like this:

    $('#tagName').autocomplete({
            lookup: countriesArray,
            onSelect: function () {
                $(this).parent().append($('<input/>', {
                    value: '',
                    type: 'text',
                    name: 'paramName1',
                    id: myDinamicId
                }));
                $('#'+myDinamicId).autocomplete({ lookup: citiesArray,... etc.
                $('#'+myDinamicId).focus();
    

    There’s a question that look a lot like yours. Check it out: jquery auto complete for dynamically generated textboxes

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

Sidebar

Related Questions

I have this simple code to place two div #container elements side by side.
What is good design in this simple case: Let's say I have a base
I have a simple case where I got a grid with an attached store.
I have a really simple set up: <div class="container"> <ul> <li>Item one</li> <li>Item two</li>
I have made a simple fragment of html, which contains this: <a href=#><div>Something here</div></a>
I have a simple test case failing in Django: Model (app/models.py): from django.db import
I have a pretty simple case which I started solving using foreach(), but then
I have a simple unit test case (extensive question here ) on a configuration
Imagine a simple case like this: class Book has_many :chapters end Let's say in
I have a div thats about 200px x 40px. Sometimes this block will contain

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.