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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:43:01+00:00 2026-05-28T01:43:01+00:00

I am using jQuery to do an autocomplete on a text field. Based on

  • 0

I am using jQuery to do an autocomplete on a text field. Based on the user click from that auto complete I want to call another function that does an ajax request. How can this be accomplished.Here is first autocomplete function:

    function lookup(inputString) {
    if(inputString.length == 0) {
        // Hide the suggestion box.
        $('#suggestions').hide();
    } else {
        $.post("ajax/autocomplete.php", {queryString: ""+inputString+""}, function(data){
            if(data.length >0) {
                $('#suggestions').show();
                $('#autoSuggestionsList').html(data);
            }
        });
    }
} // lookup

function fill(thisValue) {
    $('#inputString').val(thisValue);
    setTimeout("$('#suggestions').hide();", 200);
}

and the second ajax call:

function showCar(str)
{
if (str=="")
{
document.getElementById("inputString").innerHTML="";
return;
} 
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("carchoice").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax/getcar.php?q="+str,true);
xmlhttp.send();
}

and the initial call to the function from the form:

<input type="text" size="50" value="" id="inputString" onkeyup="lookup(this.value);" onblur="fill();"/>
<div class="suggestionsBox" id="suggestions" style="display: none;">
            <img src="images/upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
            <div class="suggestionList" id="autoSuggestionsList">
                &nbsp;
            </div>
  • 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-28T01:43:01+00:00Added an answer on May 28, 2026 at 1:43 am

    You can call it using these lines of code:

    $('#autoSuggestionsList').children('div').click(function () {
        showCar(this.innerHTML);
    });
    

    Of course in case that you’re putting each result in a new div which is child to #autoSuggestionsList:

    <div class="suggestionList" id="autoSuggestionsList">
        <div>First result</div>
        <div>Second result</div>                
    </div>
    

    And a fiddle: http://jsfiddle.net/NaYzm/

    Best regards!

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

Sidebar

Related Questions

I have an input field (text) that I want to perform autocomplete on with
I'm using an JQuery UI Autocomplete field that is tied to an ajax lookup
I'm using the following JQUERY Autocomplete plug-in: jQuery Plugin: Tokenizing Autocomplete Text Entry What'd
I'm using jQuery autocomplete plugin from jQuery website calling the controller url which return
I am using jquery.autocomplete.js and jquery.apitags to select a few elements from a div
I'm developing a form, and using jQuery UI Autocomplete. When the user selects an
I am using the jQuery autocomplete plugin and have wired up an input field
I'm using the jQuery Autocomplete plugin from http://docs.jquery.com/Plugins/Autocomplete on IE7 and it's not releasing
I am using jquery-ui's autocomplete in my project. It works great. Now I want
Beginner jquery question. I am using the Tokenizing Autocomplete Text Entry plugin, with the

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.