我试图微调自动完成文本框。我在这里的作品(虽然有点乱)。但是我想在单击文本框时显示可用的值,然后在您键入时进行过滤。另外,有没有更简单的编码方法?
<?php
session_start();
if(isset($_SESSION['myusername'])) {
$User = $_SESSION['myusername'];}
$db1 = realpath('C:\AccessBackEnds\CETracker\CETracker.accdb');
$conn1 = odbc_connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$db1",'','') or die ("Unable to connect to server");
?>
<link rel="stylesheet" href="../datepicker/jquery-ui2.css" />
<script src="../datepicker/jquery-1.9.1.js"></script>
<script src="../datepicker/jquery-ui.js"></script>
<script>
$(function() {
var availableTasks = [
<?php
$info0 = "SELECT DISTINCT TaskName FROM CT:MyTasks WHERE UserName = '$User'";
$rs0=odbc_exec($conn1,$info0);
while($row = odbc_fetch_array($rs0)) {
$TaskName = "" . $row['TaskName'] . "";
echo '"';
echo $TaskName;
echo '", ';
}
?>""];
$( "#Tasks" ).autocomplete({
source: availableTasks
});
});
</script>
<div class="ui-widget">
<label for="Tasks">Tasks: </label>
<input name="tasks" id="Tasks" style="width: 400px">
</div>