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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:57:40+00:00 2026-06-17T09:57:40+00:00

to keep things simple, I have jquery autocomplete working, what is the best way

  • 0

to keep things simple, I have jquery autocomplete working, what is the best way to approach, joining/displaying a multiple rows from the array in the same input field.

My php looks like this

$return_arr = array();

/* If connection to database, run sql statement. */
if ($conn)
{
    $fetch = mysql_query("SELECT * FROM alltickets where name like '%" . mysql_real_escape_string($_GET['term']) . "%'");

    /* Retrieve and store in array the results of the query.*/
    while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
        $row_array['id'] = $row['id'];
        $row_array['value'] = $row['name'];
        $row_array['thedate'] = $row['date'];

        array_push($return_arr,$row_array);
    }
}

/* Free connection resources. */
mysql_close($conn);

/* Toss back results as json encoded array. */
echo json_encode($return_arr);

My html page looks like

>Please enter what you are looking for</p>

<p class="ui-widget">

<label for="event">Please start entering your event </label>

<input type="text" id="event"  name="event" /></p>

<input type="hidden" id="mysqlid" name="mysqlid" />


<p><input type="submit" name="submitBtn" value="Submit" /></p>

</fieldset>
</form>

<script type="text/javascript">
$(function() {

            $("#event").autocomplete({
                source: "autocomp.php",
                minLength: 2,
                select: function(event, ui) {
                    $('#mysqlid').val(ui.item.id);
                }
            });

        });
</script>

Whats the most effective way to get “date” to be displayed in the text input field named event, right after “name”

so right now If I search, “cam” result will look as so

camera

I want result to look like

camera 17/09/2013

I can see there are a few ways to do this, whats the best way? Thank you

  • 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-17T09:57:41+00:00Added an answer on June 17, 2026 at 9:57 am

    The easiest way is probably to do it in the select event handler. Remember to prevent the default action of the event as well:

    $("#event").autocomplete({
        source: "autocomp.php",
        minLength: 2,
        select: function(event, ui) {
            event.preventDefault();
            this.value = ui.item.value + " " + ui.item.thedate;
    
            $('#mysqlid').val(ui.item.id);
        }
    });
    

    Example: http://jsfiddle.net/J5rVP/33/


    If you want to display the date inside the list of suggestions, you have a few options:

    1. Populate the value property with the entire string you want displayed (do the work on the server)
    2. Manipuate the response you get from the server to populate the value property correctly
    3. Override the _renderItem function to display the items the way you’d like.

    In your case, it seems like #3 is probably the best way to go, so here’s how you would do that:

    $("#event").autocomplete({
        source: "autocomp.php",
        select: function (event, ui) {
            event.preventDefault();
            this.value = ui.item.value + " " + ui.item.thedate;
        }
    }).data("autocomplete")._renderItem = function (ul, item) {
        return $("<li>")
            .data("item.autocomplete", item)
            .append("<a>" + item.label + " " + item.thedate + "</a>")
            .appendTo(ul);
    };
    

    Example: http://jsfiddle.net/J5rVP/34/

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

Sidebar

Related Questions

To keep things simple, lets say I have a Node class, each node has
Let's keep things simple shall we? I have a git project set up. Let's
To keep things simple, I have this class: public class Contact { public string
To keep things simple, we have a few aspx pages... Page1.aspx - resets Session
To keep things simple, please allow the assumption that some code requires the use
To keep things simplified lets say I have an interface RandomProvider interface public interface
I've been working on a quick and simple jQuery/PHP chat to put in my
I'm building a complex web app and to keep things simple, I made various
I have a jQuery UI Autocomplete control that fires an Ajax request when minLength
I'm a big fan of backing things up. I keep my important school essays

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.