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

  • Home
  • SEARCH
  • 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 8396481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:32:51+00:00 2026-06-09T20:32:51+00:00

I have a jQuery autocomplete (jquery ui version 1.8) in which I type a

  • 0

I have a jQuery autocomplete (jquery ui version 1.8) in which I type a name. When available, I want the user to select a name from the list as these are owner names from our database. However, there is the occassion where they will need to add a new owner name, and in this instance, I want them to chose “Add New” from the autocomplete’s drop down list. The problem is, if I include “Add New” as a choice in my autocomplete source data, it does not show up as a choice in the autocomplete drop down list as it does not match what the user is typing in the text box.

Below is the javascript code. I am not including the server side code, but let’s say the results from the server create a list in the drop down that such as “Add New, Betty, Bob, Cathy, Dan, Edward.” The ‘selector’ is a standard html input field of type text.

    $('.selector').autocomplete({
        autoFocus: false,
        minLength: 1,
        focus: function (event, ui) {
            $('.selector').val(ui.item.value);
            return false;
        },
        select: function (event, ui) {
            $('.selector').val(ui.item.value);
            return false;
        }
    });

    $('.selector').keyup(function(){
        // Each time a new character is entered, recreate the drop down list by matching entered characters to beginning of first name field

        $.ajax({
            type: "POST",
            url: "(url to c#.net asmx page and method)",
            contentType: "application/json; charset=utf-8",
            data: '{(various data parameters)}',
            datatype: "json",
            error: function (data) {
                var data = $.parseJSON(data.responseText);
                alert("Error: " + data.Message);
            },
            success: function (data, status, info) {
                if (data.hasOwnProperty("d")) {
                    var nameList = data.d;
                }
                else {
                    var nameList = data;
                }
                $('.selector').autocomplete("option", "source", nameList);
            }
        });
    });

I realize I’ve cut a couple of chunks out of the javascript code for the url and data portions of my ajax call, but I figured that was OK since getting my autocomplete’s “source” isn’t the issue here.

What needs to happen, is for example, when I type in the letter b, I need to see “Add New, Bill, Betty” as my three choices in the list but right now I only see “Bill, Betty” because there is no “b” in “Add New”.

Any thoughts or solutions on how to get the “Add New” choice to always be available?

Thank you very much 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-09T20:32:53+00:00Added an answer on June 9, 2026 at 8:32 pm

    I think Autocomplete builds the collection of objects retrieved into an unordered list. like ->

    <ul class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all">
      <li class="ui-menu-item">
        <a class="ui-corner-all">item 1</a>
      </li>
      <li class="ui-menu-item">
        <a class="ui-corner-all">item 2</a>
      </li>
      <li class="ui-menu-item">
        <a class="ui-corner-all">item 3</a>
      </li>
    </ul> 
    

    It also has a method to detect when the list is opened with the open event.

    $('selector').autocomplete({
      open: function(){
        $('.ui-autocomplete').prepend('<li class="ui-menu-item"><a class="ui-corner-all ui-add-new"> Add New </a></li>');
      }
    });
    

    You can see that we’ve added a list item to the auto-complete dropdown menu when it opens, so that you always get ‘Add New’ at the top of the list (jQuery’s .prepend() handles that).

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

Sidebar

Related Questions

I want to have jquery-ui autocomplete automatically select the answer if there is only
I have a jQuery autocomplete field which gets results from Amazon's autocomplete, as you
I have a jQuery autocomplete fild which gets existing data from my MVC action.
I have a jQuery autocomplete input box for time. It lists all available times
I have a problem with the jquery-autocomplete pluging and my django script. I want
I need to have an autocomplete functionality using jquery, and I've encountered ZendX_JQuery which
I have this version of jQuery-autocomplete: jQuery Autocomplete Mod , It's cool with me
I have a Jquery autocomplete ajax function whose source is calculated from code behind.
I have the autocomplete plugin ( http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/ , version 1.1 and 1.0.2) on a
I want to make my input field to have jquery autocomplete where I fetch

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.