我想用ajax創建autosuggest文本框。寫完一些字符後,它會返回電子郵件地址。從DB中的那些字符開始。這應該在JSP中開發。任何人都有想法嗎?用ajax創建autosuggest文本框
1
A
回答
0
待辦事項如下:
在javascript:
function getValue(str){
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
url = url +"?" +str;
xmlhttp.open("POST",url_to_get_db_data,false);
xmlhttp.send(null);
document.getElementById('id_of_div').innerHTML=xmlhttp.responseText;
document.getElementById('id_of_div').style.display = "block";
}
和HTML:
<input onkeypress="getValue(this.value)"/> //--- this will be your input text
<div id="id_of_div" style="display:none;"> //--- this is your autosuggest box which will appear down to textbox. Use css to show it at proper location.
</div>
格式的DIV看起來像一個自動提示框。使用css
來實現這一點。
此外,當用戶選擇從自動提示框調用Java腳本功能,並在服務器端以下 document.getElementById('id_of_div').style.display = "none";
編輯
,當你得到數據庫列表做如下一個選項:
for(Iterator it=db_list.iterator();it.hasNext();)
{
Object obj = (Object) it.next();
String value = obj.getValue();
out.print(value+"<br>");
}
希望這有助於。
0
我建議看看jQuery UI附帶的autocomplete plugin。
看看他們的official demo它說明它是如何工作的。
0
您是否看過將jQuery UI與您的Web應用程序集成? jQuery的UI具有自動完成/建議插件http://docs.jquery.com/Plugins/autocomplete
這是阿賈克斯和所有你需要做的只是提供話
相關問題
- 1. jquery autosuggest with ajax
- 2. Drew Wilson AutoSuggest和Ajax
- 3. 使用文本創建AJAX覆蓋圖
- 4. 動態創建文本框
- 5. 動態創建文本框
- 6. 創建動態文本框
- 7. onclick創建文本框
- 8. 動態創建文本框
- 9. 點擊創建文本框
- 10. jquery autosuggest創建錯誤的url請求
- 11. 用文本框和按鈕創建UITableViewCell?
- 12. 使用javascript動態創建文本框
- 13. ASP.NET使用javascript創建文本框
- 14. 用jquery創建文本框onfly
- 15. 禁用動態創建的文本框
- 16. ANDROID用戶創建文本框?
- 17. 專注於由ajax創建的文本框
- 18. 爲文本框和AJAX更新面板控件創建事件
- 19. 通過文本創建邊框並在文本週圍創建邊框
- 20. 使用ajax在JSP中進行Autosuggest?
- 21. 使用PHP/MySQL和Ajax的AutoSuggest
- 22. CakePHP - LiveSearch/AutoSuggest/AutoComplete使用AJAX/Jquery搜索
- 23. AutoSuggest在一個asp.net使用Ajax控件
- 24. Rails ajax:幫助創建文本preivew auto_html
- 25. 如何使用c創建和建議框(文本框)#
- 26. 如何用文本框的值創建文本文件名?
- 27. jquery autosuggest在單個文本框中的多個單詞
- 28. AutoSuggest附加在文本框從GridView數據?
- 29. 使用由Ajax創建的複選框
- 30. 基於文本框輸入的動態文本框創建
@Mayur的列表:我已經編輯我的問題進行更多的瞭解。看看 – 2011-02-06 17:00:06
感謝哈里....在那個網址應該是什麼邏輯比較DB中的每個字符通過'喜歡%',並在最後我會得到那些清單...我們高清設置列表smwhere?你能以這種方式解釋我嗎?...... – 2011-02-06 17:08:37