下拉框可列出数据,然后还可以由用户自行输入,如何做到这一点?
---------------------------------------------------------------
具有edit功能的combobox
1<html>
2<head>
3<public>
4<component tagname="COMBOBOX">
5<property get="get_Text" name="Text" put="put_Text">
6<property get="get_Width" name="Width" put="put_Width">
7<method internalname="htcFocus" name="SetFocus">
8<method internalname="htcAddItems" name="AddItems">
9<event id="idEnter" name="onYYCenter">
10<event id="idChoose" name="onYYCChoose">
11<attach event="oncontentready" onevent="htcInit()">
12</attach></event></event></method></method></property></property></component>
13</public>
14<script language="javascript">
15function htcInit()
16{
17defaults.viewLink=document;
18defaults.viewInheritStyle=false;
19Body_Init();
20}
21function htcAddItems(items)
22{
23var i,len;
24len=pCombo.options.length;
25for(i=0;i<len;i++)
26{pCombo.remove(0);}
27for(i=0;i<items.length;i++)
28{
29var o;
30if((typeof items[i])=='string')
31{
32if(!HasTheValue(items,i))
33{
34o=document.createElement('OPTION');
35o.text=items[i];
36pCombo.add(o);
37}
38}
39}
40}
41function htcFocus()
42{
43pText.focus();
44}
45function get_Text()
46{
47return pText.value;
48}
49function put_Text(Value)
50{
51pText.value=Value;
52}
53function get_Width()
54{
55return pCombo.style.width;
56}
57function put_Width(Value)
58{
59pCombo.style.width=Value;
60}
61</script>
62<script language="javascript">
63function Body_Init()
64{
65var iRight=pCombo.clientWidth;
66var iBottom=pCombo.clientHeight;
67var iLeft=(pCombo.clientWidth-18);
68pCombo.style.clip='rect(0,'+iRight+','+iBottom+','+iLeft+')';
69pText.style.width=(pCombo.clientWidth);
70pText.style.height=(pCombo.clientHeight);
71pText.style.top=0;
72pText.style.left=0;
73}
74function Combo_Select()
75{
76pText.value=pCombo.options[pCombo.selectedIndex].text;
77}
78function Text_ChkKey()
79{
80if(event.keyCode==13)
81{
82idEnter.fire();
83}
84}
85function HasTheValue(sitems,i)
86{
87var ii;
88for(ii=0;ii<i;ii++)
89{
90if(sitems[ii]==sitems[i])
91return true;
92}
93return false;
94}
95</script>
96</head>
97<body>
98<select name="pCombo" onchange="Combo_Select()" style="position:absolute;left:0;top:0;">
99</select>
100<input name="pText" onkeypress="Text_ChkKey()" style="position:absolute;left:0;top:0;z-index:4000" type="TEXT"/>
101</body>
102</html>