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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:41:53+00:00 2026-05-18T02:41:53+00:00

I want to make my input field to have jquery autocomplete where I fetch

  • 0

I want to make my input field to have jquery autocomplete where I fetch company names from the database and display it to the user. Below is a snippet I found on jquery.com. I want to rewrite it to fit my needs and I need some help.

$(function() {
  function log( message ) {
   $( "<div/>" ).text( message ).prependTo( "#log" );
   $( "#log" ).attr( "scrollTop", 0 );
  }

  $( "#company_name" ).autocomplete({
   source: function( request, response ) {
    $.ajax({
     url: "inc/company_name.php",
     dataType: "jsonp",
     data: {
      featureClass: "P",
      style: "full",
      maxRows: 12,
      name_startsWith: request.term
     },
     success: function( data ) {
      response( $.map( data.geonames, function( item ) {
       return {
        label: item.name,
        value: item.name
       }
      }));
     }
    });
   },
   minLength: 2,
   select: function( event, ui ) {
    log( ui.item ?
     "Selected: " + ui.item.label :
     "Nothing selected, input was " + this.value);
   },
   open: function() {
    $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
   },
   close: function() {
    $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
   }
  });
});

in the source attribute, upon sucess, I want to replace

response( $.map( data.geonames,
    function( item ) { ... }

with the proper code to display my json object data. Below is my json object created in PHP.

<?php
 $arr = array  ( 'item' => 'company name' );
 echo json_encode($arr);
?>
  • 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-18T02:41:54+00:00Added an answer on May 18, 2026 at 2:41 am

    Try their autocomplete plugin:

    http://docs.jquery.com/Plugins/autocomplete

    The Example:

    var data = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" ");
        $("#example").autocomplete(data);
    

    You could modify it to fit yours by using an ajaxloader from something like ARTE:

    http://plugins.jquery.com/node/12682

    You would use this code:

    /* init the arte engine */
    $.arte({'ajax_url':'remote_xml_file_url'}).add_action("xml_node", fct);
    
    /* the function which will be called every tick with the new node */
    function fct(data){
      window.data = data;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to make autocomplete for many text input field... but with this autocomplete
I am using the jQuery autocomplete plugin and have wired up an input field
I want to make a program in Python that can take video input from
I'm attempting to trigger Jquery autocomplete from outside the field. I'm running an on
I try to make user registation form. I have two user types and want
I want to implement jquery/js in my forms and I want to make input
I want to make sure the input is A)a number and B)has at most
I want to make this form: echo '<form method=post action=ratinghandler.php style=width: 250px> <input type=hidden
Basically, I want to make clicking anywhere on a page except in an input
I want make datetimepicker in my project. Using jquery how it is possible? I

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.