站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Javascript 专题具有edit功能的combobox

具有edit功能的combobox

摘要: 具有edit功能的combobox


这是一个自己编写的htc控件


<head>











<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 {pCombo.remove(0);}
for(i=0;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();
}
}
function HasTheValue(sitems,i)
{
var ii;
for(ii=0;ii {
if(sitems[ii]==sitems[i])
return true;
}
return false;
}
</script>
</head>
<body>
<select STYLE="position:absolute;left:0;top:0;" ONCHANGE="Combo_Select()" NAME="pCombo">
</select>
<input STYLE="position:absolute;left:0;top:0;z-index:4000" onKeyPress="Text_ChkKey()" TYPE="TEXT" NAME="pText">
</body>

</td> </tr> <tr> <td vAlign=top align=left height="100%">
↑返回目录
前一篇: Js中实现拼音和UrlEncode的功能(利用GB和Unicode对照表)
后一篇: showModalDialog()、showModelessDialog()方法使用详解