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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:35:43+00:00 2026-05-30T20:35:43+00:00

im working on this jquery data entry form in which i need a specific

  • 0

im working on this jquery data entry form in which i need a specific field to be autocompleted with data from mysql

i got everything working, autocomplete retrieves data from the sql through php matching is great in english/latin and utf8 characters

the values get retrieved from the sql as “‘number’ => ‘name'”

right now the autocomplete has 3 values in the output, value, label and id.
as id and value it uses the ‘name’
and the label is the ‘number’ of my sql string (which is posted to the next page when the form is submited)

so everyting works ok, my ‘number’ is posted correctly, there is a minor annoyance tho

when i select something from the autocomplete list, the field is populated with the ‘number’
is there any way to fill it with the ‘name’?
ie: search for ‘name’, get dropdown with ‘names’, click and get the ‘name’ in the field, and when i submit i get the ‘number’ posted?

any help would be greatly appreciated.

if you need to take a look at my code, it’s posted on a previous question: Jquery ui – Autocomplete – UTF8 charset

thanx 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-05-30T20:35:45+00:00Added an answer on May 30, 2026 at 8:35 pm

    The usual way to do this is:

    1. Use a hidden input to hold the value you’d like to POST, then autocomplete a separate field.
    2. Populate the hidden input on select
    3. Populate the visible, autocompleted input with the label property of the item that was selected.

    So, for example:

    HTML:

    <input type="hidden" name="name" />
    <input type="text" id="name_auto" />
    

    JavaScript:

    $(function () {
        var cache = {},
            lastXhr;
        $( ".name" ).autocomplete({
            minLength: 1,
            source: function( request, response ) {
                var term = request.term;
                if ( term in cache ) {
                    response( cache[ term ] );
                    return;
                }
    
                lastXhr = $.getJSON( "search.php", request, function( data, status, xhr ) {
                    cache[ term ] = data;
                    if ( xhr === lastXhr ) {
                        response( data );
                    }
                });
            },
            select: function (event, ui) {
                event.preventDefault();
                this.value = ui.item.label;
            },
            change: function (event, ui) {
                if (ui.item) { 
                    $("input[name='name']").val(ui.item.value);
                } else {
                    $("input[name='name']").val('');
                }
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got this jQuery code which is working just fine. Except on element I
$(#maincontent).animate({top:450px},1200) .html($(#+Lidentity).html()) .animate({top:0px},1000); Hi friends, This is jquery code, which is working fine. As
I am working with jQuery Data Link Plugin.And it is collecting information from textbox
I am currently working through this tutorial: Getting Started with jQuery For the two
I am trying to get this awesome JQuery plugin working with SQL Server. I
I'm working on this jQuery Autocomplete thing and I can't get the item selected
Could someone point me in the right direction here? Basically, I've got this jQuery
So, I have this jQuery .each loop, and for the most part its working
I'm working on a project where there will be a MySQL database containing data
Can anyone see why this jQuery ajax isn't working? It's supposed to run every

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.