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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:31:52+00:00 2026-05-21T14:31:52+00:00

Can someone help me find a way when i type a text in an

  • 0

Can someone help me find a way when i type a text in an Input text (eg: cars ), and the name of cars (bmw, Chevrolet, etc..) is listed in a select box.

do some one have an idea or an example?

  • 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-21T14:31:53+00:00Added an answer on May 21, 2026 at 2:31 pm

    If you are familiar with jQuery and Ajax, this can be performed very simply. You watch the input of the text box and fire off an Ajax request once it reaches a stage you are happy with. The return of the Ajax query is them used to populate a drop down box.

    Below is an example of this in practice. You’ll need to either have jquery on your server, or reference a copy held within a CDN (such as Google). I’ve had to edit it a bit in order to protect the innocent, but with a couple of more lines it’ll work fine.

    The only item you’ll need to figure out yourself, it by what means should Ajax be called and therefore your drop down list be populated. I’ve used it after so many characters, once a text pattern has been recognised, and as well as a hoover off event. The choice is yours.

    JAVASCRIPT

    <script language="JavaScript" src="./js.jquery.inc.js"></script>
    <script language="JavaScript" type="text/javascript">
    
            // This is the pure ajax call, needs some way of being called.
            $.ajax({
                url: "ajaxCode.php",
                cache: false,
                type: "POST",
                data: ({carID : $("#CARS").val()}),
                dataType: "xml",
                success: function(data){
                    populateCars(data);
                },
                error: function(data){
                    // Something in here to denote an error.
                    alert("Error no cars retrieved.");
                }
            });
    
    
            function populateCars(data)
            {
                $(data).find("node").each(function()
                {
                    var carStr = $(this).find("String").text()
                    var carKey = $(this).find("Key").text()
                    $("<option value='"+carKey+"'>"+carStr+"</option>").appendTo("#CARSLOOKUP");
                });
            }
     </script>
    

    HTML CODE

    <input type="text" id="CARS" value="" >
    <select id="CARSLOOKUP">
    </select> 
    

    AJAXCODE.PHP CODE

    <?php
        // Post code will come in as a POST variable!
        $carCode = $_POST['carID'];
    
        // Need to build up an array of cars to return, based upon the example below.
        // Preferably based upon the input given within the car code variable.
        foreach($carList as $cars)
        {
    
            $returnArray[] = array("Key" => "Vectra", "String" => "Vauxhall Vectra");
        }
    
    
        // Output the headers and data required.
        header('Cache-Control: no-cache, must-revalidate');
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
        header('Content-type: application/xml');
    
        // This simply converts the array and returns formatted XML data (functions listed below).
        $xml = new array2xml('cars');
        $xml->createNode($returnArray);
        echo $xml;
    
        exit(0);
    
        class array2xml extends DomDocument
        {
    
            public $nodeName;
    
            private $xpath;
    
            private $root;
    
            private $node_name;
    
    
            /**
            * Constructor, duh
            *
            * Set up the DOM environment
            *
            * @param    string    $root        The name of the root node
            * @param    string    $nod_name    The name numeric keys are called
            *
            */
            public function __construct($root='root', $node_name='node')
            {
                parent::__construct();
    
                /*** set the encoding ***/
                $this->encoding = "ISO-8859-1";
    
                /*** format the output ***/
                $this->formatOutput = true;
    
                /*** set the node names ***/
                $this->node_name = $node_name;
    
                /*** create the root element ***/
                $this->root = $this->appendChild($this->createElement( $root ));
    
                $this->xpath = new DomXPath($this);
            }
    
            /*
            * creates the XML representation of the array
            *
            * @access    public
            * @param    array    $arr    The array to convert
            * @aparam    string    $node    The name given to child nodes when recursing
            *
            */
            public function createNode( $arr, $node = null)
            {
                if (is_null($node))
                {
                    $node = $this->root;
                }
                foreach($arr as $element => $value) 
                {
                    $element = is_numeric( $element ) ? $this->node_name : $element;
    
                    $child = $this->createElement($element, (is_array($value) ? null : $value));
                    $node->appendChild($child);
    
                    if (is_array($value))
                    {
                        self::createNode($value, $child);
                    }
                }
            }
            /*
            * Return the generated XML as a string
            *
            * @access    public
            * @return    string
            *
            */
            public function __toString()
            {
                return $this->saveXML();
            }
    
            /*
            * array2xml::query() - perform an XPath query on the XML representation of the array
            * @param str $query - query to perform
            * @return mixed
            */
            public function query($query)
            {
                return $this->xpath->evaluate($query);
            }
    
        } // end of class
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone help explain the following: If I type: a=`ls -l` Then the output
Can someone help me identify what the purpose of this unidentified syntax is. It
Can someone help me figure out the following make file? BINS=file1 file2 file3 all:
Can someone help me with the getopt function? When I do the following in
Can someone just help me refresh my mind? How do you specify hex values
Can someone please help me out with printing the contents of an IFrame via
I am wondering if someone can help me figure out the best approach to
As a follow-up to this question I am hoping someone can help with the
I've never been much for math and I'm hoping that someone can help me
Slightly strange question, but hopefully someone can help. In essence, if the time was

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.