[問題] 用onkeydown顯示資料庫的資料

看板Ajax作者 (阿樂)時間14年前 (2010/04/06 14:22), 編輯推噓0(005)
留言5則, 3人參與, 最新討論串1/1
┌─────────────────┐ │ text div │ │ ┌─────┐ ┌──────┐ │ │ └─────┘ │ │ │ │ textarea │ │ │ │ ┌─────┐ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─────┘ └──────┘ │ └─────────────────┘ 我想在text打關鍵字 div就會在資料庫找有關關鍵字的資料.... 可是我寫出來變成 打第一個字div就顯示資料庫全部的資料 打第二個字才會針對剛第一個字顯然資料 我想要當我打a就會顯示a 當我打as就會顯示as 以下是我的程式碼 <script type="text/javascript" > function OnShowURL ( str ) { var url="date.php"; url=url+"?name="+str; url=url+"&key="+<?php echo $keytime; ?>; document.notes.target = "show"; document.notes.action = url; document.notes.submit(); } </script> <input type=text name="name" size="60" onkeydown="OnShowURL(this.value)"> <div id="abc"><form name="notes" method="post"> <iframe name="show" ></iframe> </form></div> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.38.172.42

04/06 16:44, , 1F
有沒有先檢查str的value? 另外ajax的設定設成同步試試?
04/06 16:44, 1F

04/06 17:10, , 2F
你的問題很簡單,把keydown改成 keyup就好了...
04/06 17:10, 2F

04/06 17:10, , 3F
這是時間點的問題
04/06 17:10, 3F

04/06 17:11, , 4F
keydown時是剛按下,數值還沒真的增加.
04/06 17:11, 4F

04/06 19:55, , 5F
解決了....謝謝
04/06 19:55, 5F
文章代碼(AID): #1BkjCLLs (Ajax)