2012-05-08 4 views
0

私のインデックスページINDEX.htmlとPHPページTEST.php、次に自動的にjavascriptコードがあります。Drew Wilson Auto Suggest Pluginが動作しない

私は自動候補検索フィールドを作成しようとしています。

自動出力が得られません。

NO RESULT FOUNDのみ表示されます。

誰かがhttp://code.drewwilson.com/entry/autosuggest-jquery-pluginのように自動応募をしてください。

<link href="css/autoSuggest.css" rel="stylesheet" type="text/css" /> 
<script src="js/jquery-1.4.2.min.js" type="text/javascript"></script> 
<script src="jquery.autoSuggest.js" type="text/javascript"></script> 
</head> 
<body> 
    <form id="form1" name="form1" method="post" action=""> 
     <label for="q"></label> <input style="width: 300px;" type="text" 
      name="q" id="q" /> 
     <script type="text/javascript"> 
    $(document).ready(function(){  
    $("input[type=text]").autoSuggest("test.php",{minChars: 2, matchCase: false});}); 
    </script> 
    </form> 
</body> 
</html> 

とPHPは次のよ​​うになります。

<?php include("script/core/dbcon.php"); 
$input = $_REQUEST['q']; 
$data = array(); 
// query your DataBase here looking for a match to $input 
$query = mysql_query("SELECT * FROM user WHERE username LIKE '%$input%'"); 
while ($row = mysql_fetch_assoc($query)) { 
$json = array(); 
$json['value'] = $row['id']; 
$json['name'] = $row['username']; 
$data[] = $json; 
} 
header("Content-type: application/json"); 
echo json_encode($data); 
?> 
+1

ドリューウィルソンとは誰ですか?また、あなたの質問を正しくフォーマットしてください。 – Cylindric

+1

[Drew Wilson auto suggest plugin](http://code.drewwilson.com/entry/autosuggest-jquery-plugin) – nikki

答えて

1

jQueryのは今もあなたが

$("input[type=text]").auto---- 

を交換する必要があり、同じ

を行いますオートコンプリートメソッドを持っています

$("#q").auto----- 
関連する問題