-
Notifications
You must be signed in to change notification settings - Fork 3
/
example.html
76 lines (68 loc) · 3.39 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>autoComplete示例</title>
<link rel="stylesheet" href="styles/style.css" />
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="AutoCompleteMulti.js"></script>
<body>
<div>
<label for="inpt">请输入:</label><input type="text" id="inpt" />
多个关键词以英文逗号分割
</div>
<div id="tipList" class="resultsCss">
</div>
<script type="text/javascript">
//方式1:静态数据集
//测试数据
//var staticDatas = ["asd","axcv","qwerfd","dfghj","cvbnm","bbghty","ertgb","trefgc","cssdavb","abcdefg","trefgc","cssdavb","abcdefg"];
var staticDatas = ["四大名著","四大名著-西游记","四大名著-三国演义","四大名著-水浒传","四大名著-红楼梦","四大名捕","四大名捕-冷血","四大名捕-无情","四大名捕-追命","四大名捕-铁手"];
/*
var autoCompleteOption = {
controlId: "inpt", //实现自动完成的控件ID
resultDivId: "tipList", //显示匹配结果的div的id
circleChoose: "true", //是否开启循环选择
serverEndbled: "false", //是否开启服务器端匹配
useStaticDatas:"true", //是否使用静态数据
serverEnabled: "false", //是否开启服务器端匹配
hasMultiKeyword: "true", //是否开启多关键词自动完成
datas:staticDatas
};
var auto = new AutoCompleteMulti(autoCompleteOption);
auto.init();
*/
//方式2:自定义数据获取函数
var autoCompleteOption = {
controlId: "inpt", //实现自动完成的控件ID
resultDivId: "tipList", //显示匹配结果的div的id
circleChoose: "true", //是否开启循环选择
useStaticDatas:"true", //是否使用静态数据
hasMultiKeyword: "true", //是否开启多关键词自动完成
separator:",", //设置关键词分隔符
datas:staticDatas,
getCompleteDatas: function(){ //自定义数据获取函数
var datas = null;
//enter your code to get the data
return datas;
}
};
var auto = new AutoCompleteMulti(autoCompleteOption);
auto.init();
//方式3:ajax获取数据
/*
var autoCompleteOption = {
controlId: "inpt", //实现自动完成的控件ID
resultDivId: "tipList", //显示匹配结果的div的id
circleChoose: "true", //是否开启循环选择
useStaticDatas:"true", //是否使用静态数据
datas:staticDatas,
serverEnabled: "true", //是否开启服务器端匹配
serverUrl: "AutoCompleteHandler.ashx" //服务器处理地址
};
var auto = new AutoCompleteMulti(autoCompleteOption);
auto.init();
*/
</script>
</body>
</head>
</html>