![](/css8/img/logo1.png)
本文共 7585 字,大约阅读时间需要 25 分钟。
一。得到数据集函数://数据集的填充可以用AJAX
function loadUserAddressData()
{
var emails = new Array();
var address = new addressBook("ly-dh","ly-dh@cc.com","group");
emails[emails.length] = address;
var address = new addressBook("ly_dh","ly_dh@cc.com","group");
emails[emails.length] = address;
var address = new addressBook("ly-td","ly-td@cc.com","group");
emails[emails.length] = address;
var address = new addressBook("drgydsrg","drgydsrg@cc.com","group");
emails[emails.length] = address;
var address = new addressBook("ly_td","ly_td@cc.com","group");
emails[emails.length] = address;
var address = new addressBook("htmeimei","htmeimei@cc.com","group");
emails[emails.length] = address;
var address = new addressBook("enqiu_fj","enqiu_fj@cc.com","group");
emails[emails.length] = address;
var address = new addressBook("chenzhiyou3-","chenzhiyou3-@cc.com","group");
emails[emails.length] = address;
var address = new addressBook("lyzhyuan","lyzhyuan@cc.com","group");
emails[emails.length] = address;
var address = new addressBook("shily8866","shily8866@cc.com.cn","group");
emails[emails.length] = address;
var address = new addressBook("eagle_hover","eagle_hover@cc.com","group");
emails[emails.length] = address;
var address = new addressBook("lehmen_163.com","lehmen@cc.com","group");
emails[emails.length] = address;
var address = new addressBook("support_qcidc.com","support@ccc.com","group");
emails[emails.length] = address;
var address = new addressBook("qndeny","qndeny@cccom","group");
emails[emails.length] = address;
var address = new addressBook("qiuen","qiuen@fjzkx.vicp.net","group");
emails[emails.length] = address;
var address = new addressBook("halfpenny","halfpenny@cc.com","group");
emails[emails.length] = address;
var address = new addressBook("srt21","srt21@cc.com","group");
emails[emails.length] = address;
var address = new addressBook("sunsi_163","sunsi_cc@cc.com","group");
emails[emails.length] = address;
var address = new addressBook("qiuen55","qiuen55@yahoo.com.cn","group");
emails[emails.length] = address;
var address = new addressBook("tianyi583","tianyi583@cc.com.cn","group");
emails[emails.length] = address;
var address = new addressBook("qiull3000","qiull3000@cccom.cn","group");
emails[emails.length] = address;
var address = new addressBook("cxj","cxj@ccvicp.net","group");
emails[emails.length] = address;
var address = new addressBook("51069439","51069439@cc.cn","group");
emails[emails.length] = address;
var address = new addressBook("陈峰","chenz@ccvicp.net","group");
emails[emails.length] = address;
var address = new addressBook("陈锦秀","cjx@cc.vicp.net","group");
emails[emails.length] = address;
var address = new addressBook("黄陈林","hcl@cc.vicp.net","group");
emails[emails.length] = address;
var address = new addressBook("潘总","pqb@cc.vicp.net","group");
emails[emails.length] = address;
var address = new addressBook("小苏","sufy@cc.vicp.net","group");
emails[emails.length] = address;
var address = new addressBook("小庄","zhuangjq@cc.vicp.net","group");
emails[emails.length] = address;
var address = new addressBook("尤政伟","yzw@cc.vicp.net","group");
emails[emails.length] = address;
var address = new addressBook("余秀容","yxr@cc.vicp.net","group");
emails[emails.length] = address;
var address = new addressBook("周海波","zhbs@dd.vicp.net","group");
emails[emails.length] = address;
var address = new addressBook("webmaster","webmaster@dd.com","group");
emails[emails.length] = address;
var address = new addressBook("博客园","support@ddd.com","group");
emails[emails.length] = address;
var address = new addressBook("zhbs2002","zhbs2002@dd.com","group");
emails[emails.length] = address;
var address = new addressBook("yanyan123","yanyan123@dd.163.com","group");
emails[emails.length] = address;
emails.sort();
return emails;
}
function addressBook(nickname,email,group){
this.nickname = nickname;
this.email = email;
this.group = group;
this.compare = function(compareStr){
if( startWithStr(nickname,compareStr) || startWithStr(email,compareStr) ){
var str = "";
if(startWithStr(nickname,compareStr)){
str += ('"'+this.display(nickname,compareStr.length)+'"');
}else{
str += ('"'+nickname+'"');
}
if(startWithStr(email,compareStr)){
str += ('<'+this.display(email,compareStr.length)+'>');
}else{
str += ('<'+email+'>');
}
return str;
}
return false;
}
this.display = function(str,strLen){
var first = str.substring(0,strLen).bold();
var last = str.substring(strLen,str.length);
return (first+last);
}
this.tostring = function(){
return ('"'+nickname+'"')+('<'+email+'>');
}
}
function show(){
alert("ASCII代码是:"+event.keyCode) ; } //键盘的ASCII
二、显示层函数:(对数据集合进行操作既上面得到的数据集)
function displayDIV(e){
if(pressKey == 40 || pressKey == 38){ //遇到“(”,“&”返回
return;
}
var addressInfo = loadUserAddressData(); //得到结果集合
var srcValue = document.getElementById(srcFocusId).value; //srcFocusId是文本框控件名称
//alert(srcValue);
startPosition = getLastPosition(srcValue);
var inputValue = srcValue.substring(startPosition+1,srcValue.length);
inputValue = trim(inputValue); //输入的EMAIL地址
var displayAll = false;
// 如果是空格键,并且输入的值为空,则默认查询出所有的数据
if((pressKey == 32) && inputValue == ""){
displayAll = true;
}else{
if(inputValue == ""){
document.getElementById(divId).style.display = "none"; //divId是层ID
return;
}
}
var matchedList = "";
for(var i=0,j=0;i
if(j > 50){
break;
}
var addressBook = addressInfo[i];
// alert(addressBook);
if(displayAll){ //如果是默认查询全部,则直接将数据显示
matchedList += "
j++;
continue;
}
// 否则,按照输入的字符进行比较
var element = addressBook.compare(inputValue); //与输入的值进行比较
if(element){
matchedList += "
j++;
}
}
if(trim(matchedList) == ""){
document.getElementById(divId).style.display = "none";
return;
}
alert(matchedList);
document.getElementById(divId).innerHTML = matchedList+"";
selectedId = "eleinfo0";
MM_changeBg(selectedId);
setAddressPosition(srcFocusId);
document.getElementById(divId).scrollTop = 0;
}
function getLastPosition(str){ //得到EMAIL地址的最后的位置
var position1 = str.lastIndexOf(",");
var position2 = str.lastIndexOf(";");
if(position1 >= position2){
return position1;
}
return position2;
}
function selectedRow(rowId){
var parseTo = document.getElementById(srcFocusId);
parseTo.focus();
parseTo.value = parseTo.value.substring(0,startPosition+1);
document.getElementById(divId).style.display = "none"; //隐藏层
var content = getInnerText(rowId); //根据行ID得到EMAIL值
document.getElementById("charset_code").style.visibility = "visible";
if(isExsitInSource(parseTo.value,content)){
return;
}
parseTo.value += content +",";
}
function getInnerText(id){
var content = "";
if (window.XMLHttpRequest){
content = document.getElementById(id).textContent;
}else{
content = document.getElementById(id).innerText;
}
return content;
}
//看是否存在EMAIL
function isExsitInSource(source,str){
source = source.toLowerCase();
str = str.toLowerCase();
if(source.indexOf(str) != -1){
return true;
}
return false;
}
function MM_changeBg(id){
try{
MM_returnBg(selectedId);
}catch(ex){
}
changBgColor(id,"#E2F0D9");
selectedId = id;
}
function MM_returnBg(id){
changBgColor(id,"#F8FEF4");
}
ASCII码
键盘
ASCII 码
键盘
ASCII 码
键盘
ASCII 码
键盘
27
ESC
32
SPACE
33
!
34
35
#
36
$
37
%
38
&
39
'
40
(
41
)
42
*
43
+
44
'
45
-
46
.
47
/
48
0
49
1
50
2
51
3
52
4
53
5
54
6
55
7
56
8
57
9
58
:
59
;
60
<
61
=
62
>
63
?
64
@
65
A
66
B
67
C
68
D
69
E
70
F
71
G
72
H
73
I
74
J
75
K
76
L
77
M
78
N
79
O
80
P
81
Q
82
R
83
S
84
T
85
U
86
V
87
W
88
X
89
Y
90
Z
91
[
92
\\
93
]
94
^
95
_
96
`
97
a
98
b
99
c
100
d
101
e
102
f
103
g
104
h
105
i
106
j
107
k
108
l
109
m
110
n
111
o
112
p
113
q
114
r
115
s
116
t
117
u
118
v
119
w
120
x
121
y
122
z
123
{
124
|
125
}
126
~
转载地址:https://blog.csdn.net/weixin_33352628/article/details/114729664 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
关于作者
![](/css8/img/my2.jpg)