I have linked to the appropriate ajax library for autocomplete and jquery. Here is the script
jQuery(document).ready(function($) {
$("#tag").autocomplete("data.php", {
selectFirst: true
});
});
and my data.php file
$q = $_GET["q"];
$my_data=mysql_real_escape_string($q);
$sql="SELECT comname FROM wp_birds WHERE comname LIKE '%$my_data%' ORDER BY comname";
$result = mysql_query($sql) or die(mysql_error());
if($result)
{
while($row=mysql_fetch_array($result))
{
echo $row['comname']."
";
}
}
and my form
<label>Tag:</label>
<input name="tag" type="text" id="tag" size="20"/>
the data.php file is successfully loading the array of comnames however when i input i'm getting nothing...
jquery noconflict wrapper
jQuery(document).ready(function($) {
$("#tag").autocomplete("data.php", {
selectFirst: true
});
});
reference: http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers
Update:
You also need to retrieve your source using ajax
the jquery library included with wordPress loads in "no conflict" mode. This is done to prevent compatibility problems with other javascript libraries. In "no-confict" mode, the $ shortcut is not available and the longer jquery is used, Example :
jQuery(document).ready(function ($) {