Hi everyone, I am new at programming and I cannot figure out how to
get the Autocomplete's keyboard functionality to work correctly. I am
able to get Autocomplete function but when you hit the up and down
arrow, the select does not change. Could someone take a look at my
code and point out what I am doing wrong? I am using the latest stable
version of script.aculo.us.

FILE: autocomplete.php
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>Autocomplete demonstration</title>
        <script type="text/javascript" src="javascripts/prototype.js"></
        <script type="text/javascript" src="javascripts/effects.js"></script>
        <script type="text/javascript" src="javascripts/controls.js"></
        body {font-family: verdana; arial, sans-serif; font-size: 12px; }
        #search, ul { padding: 3px; width: 150px; border: 1px solid #999;
font-family: verdana; arial, sans-serif; font-size: 12px;}
        ul { list-style-type: none; font-family: verdana; arial, sans-serif;
font-size: 12px;  margin: 5px 0 0 0}
        li { margin: 0 0 5px 0; cursor: default; color: red;}
        li:hover { background: #ffc; }
<h2>Autocompletion example</h2>
The database searches a few of my favourite musicians - the best place
to start is by typing "the";
                <label>Type here</label> <input type="text" id="search"
name="search" />
        <div id="hint"></div>
        <script type="text/javascript">
                new Ajax.Autocompleter("search","hint","livesearch2.php");

FILE: livesearch2.php

$xmlDoc=new DOMDocument();


//get the q parameter from URL
//lookup all links from the xml file if length of q>0
if (strlen($q)>0)
        for($i=0; $i<($x->length); $i++)
                        $music = $x->item($i);
                        $music_id = 

                        if ($z->item(0)->nodeType==1)

                                //find a link matching the search text
                                        echo("\t<li id=\"" . $j++ . "\" >");

FILE: artists.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
                <id> 4 </id>
                <title>The Clash</title>
                <id> 5 </id>
                <title>Animal Collective</title>
        <music ID="6">
                <id> 6 </id>
                <id> 7 </id>
                <title>The Dead Kennedys</title>
                <id> 8 </id>
                <title>Bad Religon</title>
                <id> 9 </id>
                <title>Minor Threat</title>

I have tried the same approach except using a SQL server instead of
searching an XML file and I get the same results. Any help or tips
would be greatly appreciated.

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to