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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:40:47+00:00 2026-05-25T01:40:47+00:00

i have an input that generates a positioned unordered list when someone enters a

  • 0

i have an input that generates a positioned unordered list when someone enters a key into it, and it finds a match via the DB.

the problem is, its not populating the input field when clicking on a list item. its very simple and should be working.

heres my html:

<p style="position: relative;">
<input id="qbid" value="Enter Customer Name" size="40" />
<div id="qbid_res"></div>
</p>

heres my jquery:

$('#qbid_res ul li a').click(function(e) {
    e.preventDefault();
    $('#qbid').val($(this).html()); 
    $('#qbid_res').css('display', 'none'); 
}); 
$('#qbid').keyup(function() {
    $.ajax({
        type: "POST",
        url: "ajax-qbid.php",
        data: { name : $('#qbid').val() },
        dataType: "text",
        success: function(data){
            if (data.length > 0)
            {       
                $('#qbid_res').html(data); 
                $('#qbid_res').css('display', 'block');         
            }
        }
    });
});

heres my php/mysql in ajax-qbid.php:

<ul>

<?php

include 'connect.php';

$sql = mysql_query("select `name` from `customers` where `name` like '%".mysql_real_escape_string($_POST['name'])."%' order by `name` asc");

while ($row = mysql_fetch_assoc($sql))
    echo '<li><a href="#">'.$row['name'].'</a></li>';

?>

</ul>

before i introduced the ajax code, it was working fine. i mean it does show the list when i enter a value that will match in the DB, but like i said clicking on one of the names does not populate the input field.

  • 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-25T01:40:47+00:00Added an answer on May 25, 2026 at 1:40 am

    You have to use jQuery live because the elements are not present before making a ajax call so click handlers will not be attached.

    $('#qbid_res ul li a').live('click', function(e) {
        e.preventDefault();
        $('#qbid').val($(this).html()); 
        $('#qbid_res').css('display', 'none'); 
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an algorithm that generates strings based on a list of input words.
I have an application that takes some input and generates configuration files as output.
I have a javascript function being called by an input type=image tag that generates
I have this test page http://thechozenfew.net/projects/write_font.php that generates the text in the input box
I have some javascript code that generates additional input fields. So, I can know
I have an app that generates a docx file base on user input. It
I have a PHP script that generates table rows with hidden input tags that
I'm trying to build something on javascript that I can have an input that
We have some input data that sometimes appears with &nbsp characters on the end.
I have an input file that I want to sort based on timestamp which

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.