fangsnan 發表於 2010-7-1 08:25
[b]回復 [url=http://jsgears.com/redirect.php?goto=findpost&pid=1431&ptid=114]120#[/url] [i]wmh[/i] [/b]
問題已經解決了,謝謝您!
ckt1105 發表於 2010-8-6 16:21
[b]回復 [url=http://jsgears.com/redirect.php?goto=findpost&pid=1358&ptid=114]110#[/url] [i]felix0131[/i] [/b]
Hi,
我試出來了!不能用<br>,要用vbcrlf就ok嚕!!
希望對你有幫助!!
wmh 發表於 2010-8-6 19:24
[b]回復 [url=http://jsgears.com/redirect.php?goto=findpost&pid=1490&ptid=114]122#[/url] [i]ckt1105[/i] [/b]
原來是換行的問題 :)
ytlin 發表於 2010-11-25 10:23
Dear 版主,
在網路上很難找到 jquery 的 JSP 範例程式.
昨日用此論壇討論說明, 改寫 Viral Patel 的[url=http://viralpatel.net/blogs/2009/06/tutorial-create-autocomplete-feature-with-java-jsp-jquery.html] Tutorial: Create Autocomplete feature with Java – JSP / jQuery[/url].
1. auto_tString.jsp (亦可寫為 .html)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/jquery.autocomplete.css" />
<script type="text/javascript" src="./js/jquery.js"></script>
<script type='text/javascript' src='./js/jquery.autocomplete.js'></script>
<script type='text/javascript' src='./js/jquery.ajaxQueue.js'></script>
<script type="text/javascript">
$(function() {
$("#tString").autocomplete("test_auto.jsp", {minChars: 0,
max: 12,
autoFill: true,
mustMatch: false,
matchContains: false,
scrollHeight: 240});
});
</script>
</head>
<body>
<p>
tString AutoComplete <input type="text" name="tString" id="tString" />
</body>
</html>
2. test_auto.jsp
<%@page import="java.util.Iterator"%>
<%@page import="java.util.List,java.util.ArrayList"%>
<%
// DummyDB db = new DummyDB();
String query = request.getParameter("q");
List<String> tt=new ArrayList<String>();
tt.add("aaa");
tt.add("abbc");
tt.add("accd");
tt.add("adde");
Iterator<String> iterator = tt.iterator();
while(iterator.hasNext()) {
String tString = (String)iterator.next();
out.println(tString);
}
%>
兩個程式即使用 Ajax 完成 Autocomplete, 將 tt.add 放入資料庫 SELECT 出來的 Data.
應該可以完成 Database 的 Autocomplete 功能.
stq22333 發表於 2011-7-1 08:58
版主,你好:
因為這個範例都是必須先輸入一個文字才會搜尋,
我想請問是否有支援滑鼠點一下就會列出所有選項的效果呢??
如果有要在哪裡做設定或更改呢??
謝謝~
Federer 發表於 2011-10-6 14:15
wmh大大,您好,最近剛好在研究jquery的autocomplete,看到您的文章,
也成功的試出第一種方法~~
但是現在我想要進行將text的值,即時抓取資料庫的資訊~~所以需要使用到資料庫,但是由於剛剛接觸jquery,所以要如何進行資料庫的搜尋和Autocomplete沒有任何頭緒,不知道您是否有相關的code可以提供給我參考,感謝您的指教,謝謝
我是用asp,而db mssql~~
wmh 發表於 2011-10-7 08:17
[b]回復 [url=http://jsgears.com/redirect.php?goto=findpost&pid=2832&ptid=114]126#[/url] [i]Federer[/i] [/b]
從資料庫撈取資料的部份請參考一般程式語言的書籍,大多都會寫到喔。
簡單的說如果從 q 取得參數後,要進資料庫讀取,可以用以下 SQL[code]
SELECT a, b, c FROM your_table WHERE field LIKE 'q%'
[/code]
Federer 發表於 2011-10-7 17:53
[b]回復 [url=http://jsgears.com/redirect.php?goto=findpost&pid=2833&ptid=114]127#[/url] [i]wmh[/i] [/b]
大大,我知道如何去select,只是我目前不知道在seachDB.asp的那裡要如何將得到的資料回傳
假設db裡有台灣各城市
我的seachDB.asp
tSql = "select * from Country where countryName like '%cName%'"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open tSql, conn, 3
我會抓到多筆資料,但是要如何讓他回傳至原始"Country.asp"中並呈現出來呢?
ienfuchen 發表於 2012-9-18 19:17
[b]回復 [url=http://jsgears.com/redirect.php?goto=findpost&pid=173&ptid=114]1#[/url] [i]wmh[/i] [/b]
要改用POST的方式而不是用GET
是直接在參數加上type: "POST",?
因為加了好像一樣被用GET送出....