1
<html>
2
<head>
3
<title>Untitled Document</title>
4
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
5
<style>
6
.table1{background-color:white;FONT-FAMILY: Courier New, Courier;font-size:12px}
7
.td_out{FONT-FAMILY: Courier New, Courier;font-size:12px;color:#000000;height:15px;border:1 solid #ffffff;}
8
.td_over{FONT-FAMILY: Courier New, Courier;font-size:12px;cursor:default;background-color:#3366cc;border:1 solid #000000;color:#ffffff;height:15px}
9
.slv{vertical-align:bottom;FONT-FAMILY: Courier New, Courier;font-size:12px;border-left-width:0;border-top-width:0;border-bottom-width:0;border-right:0 solid #000000;vertical-align:middle;height:18px;color:#000000;}
10
.down{position:relative;left:-2px;font-size:11px;vertical-align:middle;width:16;height:16;color:#2050b0;background-color:#D0DFF7;border:1 solid #9fA3Ce;writing-mode:tb-rl;font-weight:bold;
11
}
12
.seldiv{
13
position:absolute;z-index:1000;overflow-x:hidden;border-left:1 solid #000000;border-bottom:1 solid #000000;border-right:1 solid #000000;
14
SCROLLBAR-FACE-COLOR: #d0dff7;
15
SCROLLBAR-HIGHLIGHT-COLOR: #d0dff7;
16
SCROLLBAR-SHADOW-COLOR: #FFFFFF;
17
SCROLLBAR-3DLIGHT-COLOR: #FFFFFF;
18
SCROLLBAR-ARROW-COLOR: #ffffff;
19
SCROLLBAR-TRACK-COLOR: #ffffff;
20
SCROLLBAR-DARKSHADOW-COLOR: #d0dff7;}
21
</style>
22
<script language="JavaScript">
23
document.onclick=hiddenDiv;
24
function getDivCount() {
25
var arr=document.all;
26
re=0;
27
for (i=0;i<arr.length;i++) {
28
str=arr[i].id;
29
if (str.indexOf("ZfDiv_")==0) {
30
re++;
31
}
32
}
33
return re;
34
}
35
36
function getI(ObjId) {//取得objId的最后一位數字
37
for (i=0;i<ObjId.length;i++) {
38
if (ObjId.charAt(i)=="_") return ObjId.substr(i+1,ObjId.length-1);
39
}
40
return 0;
41
}
42
43
function select_edit(TextObj){//鼠標經過高亮度
44
TextObj.focus();TextObj.select();
45
}
46
47
function checkValue(ID){
48
var sl=document.all["ZfText_"+ID];
49
var sv=document.all["ZfDiv_"+ID];
50
var da=document.all["ZfData_"+ID];
51
sv.style.display=''
52
53
for(i=0;i<da.rows.length;i++)da.rows[i].style.display=''
54
55
for(i=0;i<da.rows.length;i++){
56
if(da.rows[i].cells[0].innerText.indexOf(sl.value)!=0)da.rows[i].style.display='none';
57
getPosition(ID);
58
}
59
}
60
61
function getL(e){
62
var l=e.offsetLeft;
63
while(e=e.offsetParent){
64
l+=e.offsetLeft;
65
}
66
return l
67
}
68
function getT(e){
69
var t=e.offsetTop;
70
while(e=e.offsetParent){
71
t+=e.offsetTop;
72
}
73
return t
74
}
75
76
function getPosition(ID){
77
var sv=document.all["ZfDiv_"+ID];
78
var sl=document.all["ZfText_"+ID];
79
var spn=document.all["ZfSpan_"+ID];
80
var da=document.getElementById("ZfData_"+ID);
81
sv.style.pixelWidth=spn.offsetWidth;
82
da.style.pixelWidth=sv.offsetWidth;
83
sv.style.pixelLeft=getL(spn);
84
sv.style.pixelTop=getT(spn)+sl.offsetHeight+3;
85
if(da.offsetHeight>200){
86
sv.style.pixelHeight=200;
87
sv.style.overflowY='scroll';
88
}
89
else {
90
sv.style.pixelHeight=da.offsetHeight;
91
sv.style.overflowY='hidden';
92
}
93
}
94
95
function dropDown(ID){
96
var sv=document.all["ZfDiv_"+ID]
97
var tb=document.all["ZfData_"+ID]
98
99
if(sv.style.display=='none'){
100
sv.style.display='';
101
for(i=0;i<tb.rows.length;i++)tb.rows[i].style.display=''
102
getPosition(ID);
103
} else {
104
sv.style.display='none';
105
}
106
}//下拉摸擬層
107
108
function hiddenDiv(){
109
var o=window.event.srcElement.id;
110
var tb
111
var sv
112
if(o=="") {
113
for (j=0;j<getDivCount();j++) {
114
tb=document.getElementById('ZfData_'+j);
115
sv=document.getElementById('ZfDiv_'+j);
116
for(i=0;i<tb.rows.length;i++) tb.rows[i].style.display='';
117
sv.style.display='none';
118
}
119
120
}
121
122
}//隱藏模擬層
123
124
125
function setValue(obj){
126
var i=getI(obj.parentElement.parentElement.parentElement.id);
127
//alert(obj.parentElement.parentElement.parentElement.id);
128
129
var sl=document.all["ZfText_"+i];
130
var sv=document.all['ZfDiv_'+i];
131
sl.value=obj.innerText;
132
sv.style.display='none';
133
//sldIndex=obj.parentElement.rowIndex;
134
}//給文本框賦值
135
136
function over(obj){
137
obj.className="td_over"
138
obj.title=obj.innerText
139
obj.focus();
140
}//鼠標經過變色
141
142
function out(obj){
143
obj.className="td_out"
144
}//鼠標離開還原
145
146
function String.prototype.Trim(){return this.replace(/(^\s*)|(\s*$)/g,'')}//自定義去空格函數Trim()
147
148
149
//增加list的接口,ID表示該組控件是頁面中的第幾個
150
function add(v,ID){
151
var sv=document.all['ZfDiv_'+ID];
152
if(!v.Trim()){return;}
153
var tb=document.all['ZfData_'+ID];
154
var c=tb.insertRow(tb.rows.length).insertCell();
155
c.innerHTML='<nobr>'+v.Trim()+'</nobr>';
156
c.onmouseover=new Function("over(this)");
157
c.onmouseout=new Function("out(this)");
158
c.onclick=new Function("setValue(this)");
159
c.className="td_out";
160
v='';
161
}
162
//增加inpnubox的接口,在頁面中產生一個inputbox控件,下拉列表為空
163
function addText(name,DefValue) {
164
var i=getDivCount();
165
document.write('<span id="ZfSpan_'+i+'" style="border:1 solid #9CA0CB">');
166
document.write('<input type="text" value="'+DefValue+'" name="'+name+'" id="ZfText_'+i+'" ondblclick="ZfDrop_'+i+'.click()" class="slv" onmouseover="select_edit(this)" onkeyup="checkValue('+i+')"><input type=button id="ZfDrop_'+i+'" value=">" onclick="this.hideFocus=true;dropDown('+i+');" class="down" onmouseover="this.style.backgroundColor=#EEF3FD" onmouseout="this.style.backgroundColor=\'\'" onmousedown="this.style.backgroundColor=#ABC4F5" onmouseup="this.style.backgroundColor=\'\'"></span>');
167
document.write('<div id="ZfDiv_'+i+'" class="seldiv" style="display:none;"><table id="ZfData_'+i+'" onselectstart="return false" border="0" cellspacing="0" cellpadding="0" class="table1"></table></div>');
168
}
169
170
171
172
</script>
173
</head>
174
<body>
175
176
<script language="JavaScript">
177
addText("name1","a");
178
add("1234",0);
179
add("1234",0);
180
</script>
181
</body>
182
</html>
183
184

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

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184
