日期:2010-07-13 浏览次数:20932 次
下拉框可列出数据,然后还可以由用户自行输入,如何做到这一点?
具有edit功能的combobox
<HTML>
<HEAD>
<PUBLIC>
<COMPONENT TAGNAME="COMBOBOX">
<PROPERTY NAME="Text" GET="get_Text" PUT="put_Text">
<PROPERTY NAME="Width" GET="get_Width" PUT="put_Width">
<METHOD NAME="SetFocus" INTERNALNAME="htcFocus">
<METHOD NAME="AddItems" INTERNALNAME="htcAddItems">
<EVENT NAME="onYYCenter" ID="idEnter">
<EVENT NAME="onYYCChoose" ID="idChoose">
<ATTACH EVENT="oncontentready" ONEVENT="htcInit()">
</COMPONENT>
</PUBLIC>
<SCRIPT LANGUAGE="javascript">
function htcInit()
{
defaults.viewLink=document;
defaults.viewInheritStyle=false;
Body_Init();
}
function htcAddItems(items)
{
var i,len;
len=pCombo.options.length;
for(i=0;i<len;i++)
{pCombo.remove(0);}
for(i=0;i<items.length;i++)
{
var o;
if((typeof items[i])=='string')
{
if(!HasTheValue(items,i))
{
o=document.createElement('OPTION');
o.text=items[i];
pCombo.add(o);
}
}
}
}
function htcFocus()
{
pText.focus();
}
function get_Text()
{
return pText.value;
}
function put_Text(Value)
{
pText.value=Value;
}
function get_Width()
{
return pCombo.style.width;
}
function put_Width(Value)
{
pCombo.style.width=Value;
}
</SCRIPT>
<SCRIPT LANGUAGE="javascript">
function Body_Init()
{
var iRight=pCombo.clientWidth;
var iBottom=pCombo.clientHeight;
var iLeft=(pCombo.clientWidth-18);
pCombo.style.clip='rect(0,'+iRight+','+iBottom+','+iLeft+')';
pText.style.width=(pCombo.clientWidth);
pText.style.height=(pCombo.clientHeight);
pText.style.top=0;
pText.style.left=0;
}
function Combo_Select()
{
pText.value=pCombo.options[pCombo.selectedIndex].text;
}
function Text_ChkKey()
{
if(event.keyCode==13)
{
idEnter.fire();
}