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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:08:38+00:00 2026-06-12T03:08:38+00:00

I have a jQuery autocomplete script in my page, and if I type in

  • 0

I have a jQuery autocomplete script in my page, and if I type in the field it works on, and as requested after 3 characters, the drop containing the expected number of suggestions pops down…sort of…as there is no text in the drop down.

If I mouse over the drop down as though I were selecting one of the suggestions, a narrow bar shows a highlight for each row where a suggestion would be, but selection of one of the empty highlights empties the field. This is not surprising. I don’t really understand the handling of the return data. I have seen very simple and complex code in autocomplete examples in other posts in these forums, but using the ones I thought I understood has usually broken it to the point where I don’t get the drop down at all. Thus I’m unashamedly looking for someone to provide me with the code that works so I can pick it apart and work out how it works.

My basic JS code is:

    $("#tf_txt_CLIENTNAME").autocomplete({
        source: "search.php",
        minLength: 3,//search after three characters
        dataType: 'json',
        select: function(event,ui){

            //do domething

        }

It’s the do something area I just can’t get right. As I said, I’ve tried too many variations of code in that space to mention here, and all of them broke it completely.

search.php produces the following JSON output for input of ‘bra’:

[{"txt_CLIENTNAME":"Braedon"},{"txt_CLIENTNAME":"Bradly"}]

from the following PHP source (borrowed and modified from another web source):

<?php
require_once 'includes/dbiconnect.php';
require_once 'includes/sqlfunctions.php';

$term = trim(strip_tags(addslashes($_GET['term']))); //retrieve the search term that autocomplete sends

$qstring = "SELECT `txt_CLIENTNAME` FROM `tbl_client_details` WHERE `txt_CLIENTNAME` LIKE '%".$term."%'";
$result = mysqli_query($db_link,$qstring); //query the database for entries containing the term

while ($row = mysqli_fetch_assoc($result)) {//loop through the retrieved values
        $row['txt_CLIENTNAME']=htmlentities(stripslashes($row['txt_CLIENTNAME']));
        $row_set[] = $row; //build an array
}
echo json_encode($row_set); //format the array into json data
?>

I simply would like it to display what it finds and plonk the one I select into the value of the text field. I can then update the other fields I want to populate (company, phone # & e-mail) using $.POST triggered by the onchange event for that field (I’m sure there are better ways to do that, but I understand how to do that for the moment).

I’m using jQuery 1.7.2 and jQuery UI 1.8.22. I have the latest jquery toolbox loading as well without the tabs component, but removing it has made no difference.

Thanks in advance,

Braedon

  • 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-12T03:08:40+00:00Added an answer on June 12, 2026 at 3:08 am

    As per Jquery UI guide,

    your JSON needs to contain label or value (or both)

    You need to change your json as below

    while ($row = mysqli_fetch_assoc($result)) {//loop through the retrieved values
            $row['txt_CLIENTNAME']=htmlentities(stripslashes($row['txt_CLIENTNAME']));
            $row_set[] = array('label'=>'txt_CLIENTNAME','value'=>$row['txt_CLIENTNAME']); //build an array
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with the jquery-autocomplete pluging and my django script. I want
I have a jQuery Autocomplete field on an ASP.Net Webform and everything has been
I have an jQuery.autocomplete field presenting a limited range of decimal numbers. Ex: var
I have a jquery autocomplete field working fine followed by a date input field.
I have two jQuery autocomplete textboxes on a mvc web page. One that returns
I have a jQuery text box autocomplete script which uses a PHP script to
I have the jquery autocomplete example working on a test page, but can't seem
I have a test server with a page using jquery autocomplete. The autocomplete feature
I have a site with a form with autocomplete using jquery. It works fine,
I have the following page : <html> <head> <link type=text/css href=css/smoothness/jquery-ui-1.8.14.custom.css rel=stylesheet /> <style

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.