-
Notifications
You must be signed in to change notification settings - Fork 0
/
表格搜索.html
82 lines (77 loc) · 1.64 KB
/
表格搜索.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
77
78
79
80
81
82
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>表格搜索</title>
<script type="text/javascript">
window.onload=function(){
var oTxt=document.getElementById('name');
var oBtn=document.getElementById('btn1');
var oTa=document.getElementById('tab1');
oBtn.onclick=function(){
for(var i=0;i<oTa.tBodies[0].rows.length;i++){
var stab=oTa.tBodies[0].rows[i].cells[1].innerHTML.toLowerCase();
var stxt=oTxt.value.toLowerCase();
var arr=stxt.split('');
oTa.tBodies[0].rows[i].style.display="none";
for(var j=0;j<arr.length;j++){
if(stab.search(arr[j])!=-1){
oTa.tBodies[0].rows[i].style.display="block";
}
}
}
};
};
</script>
</head>
<body>
姓名:<input id="name" type="text" />
<input id="btn1" type="button" value="搜索" />
<table id="tab1" border="1" width="500">
<thead>
<td>ID</td>
<td>姓名</td>
<td>年龄</td>
<td>操作</td>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Blue</td>
<td>27</td>
<td></td>
</tr>
<tr>
<td>2</td>
<td>张三</td>
<td>23</td>
<td></td>
</tr>
<tr>
<td>3</td>
<td>李四</td>
<td>28</td>
<td></td>
</tr>
<tr>
<td>4</td>
<td>王五</td>
<td>25</td>
<td></td>
</tr>
<tr>
<td>5</td>
<td>张伟</td>
<td>24</td>
<td></td>
</tr>
<tr>
<td>6</td>
<td>王四</td>
<td>24</td>
<td></td>
</tr>
</tbody>
</table>
</body>
</html>