xieyj(原作)
<Html>
<Cabeça>
<SCRIPT LANGUAGE="JavaScript">
<!--
//定义 select 原值
var valorantigo,Textoantigo;
//select下拉框的onkeydown事件,修改下拉框的值
função catch_keydown(sel)
{
mudar(event.keyCode)
{
caso 13: //回车键
event.returnValue = falso;
quebrar;
caso 27: //Esc键
sel.options[sel.selectedIndex].text = oldText;
sel.options[sel.selectedIndex].value = oldValue;
event.returnValue = falso;
quebrar;
caso 8: //空格健
var s = sel.options[sel.selectedIndex].text;
s = s.substr(0,s.comprimento-1);
if (sel.options[sel.selectedIndex].value==sel.options[sel.selectedIndex].text)
{
sel.options[sel.selectedIndex].value=s;
sel.options[sel.selectedIndex].text=s;
}
event.returnValue = falso;
quebrar;
}
if (!event.returnValue && sel.onchange)
sel.onchange(sel)
}
//select下拉框的onkeypress事件,修改下拉框的值
função catch_press(sel){
if(sel.selectedIndex>=0){
var s = sel.options[sel.selectedIndex].text + String.fromCharCode(event.keyCode);
if (sel.options[sel.selectedIndex].value==sel.options[sel.selectedIndex].text)
{
sel.options[sel.selectedIndex].value=s;
sel.options[sel.selectedIndex].text=s;
}
event.returnValue = falso;
if (!event.returnValue && sel.onchange)
sel.onchange(sel)
}
}
//select下拉框的onfocus事件,保存下拉框原来的值
função catch_focus(sel) {
oldText = sel.options[sel.selectedIndex].value;
oldValue = sel.options[sel.selectedIndex].value;
}
//恢复select下拉列表当前选中的值
função LoadSelect(obj,valor)
{
for (var i=0; i< obj.options.length; i++)
if (obj.options[i].valor == valor)
{
obj.selectedIndex = i;
quebrar;
}
}
//selecione 选择框鼠标上移时提示选择的内容
função selMouseOver(obj)
{
com (document.all.div_hint)
{
innerText = obj.options[obj.selectedIndex].text;
if (innerText.length > 0)
{
TextoInterior = " " + TextoInterior + " ";
style.display = "bloco";
estilo.esquerda = evento.clientX + 16;
estilo.top = evento.clientY;
}
}
}
//selecione 选择框鼠标移开时消失
função selMouseOut(obj)
{
com (document.all.div_hint)
{
estilo.display = "nenhum"
}
}
//-->
</SCRIPT>
</Cabeça>
<Corpo>
<!--调用-->
<select style='width:130px;z-index:-1' name='tmpSel' onmouseover=selMouseOver(this) onmouseout=selMouseOut(this) onkeydown=catch_keydown(this) onkeypress=catch_press(this) onfocus=catch_focus(this )>
<option value=''></option>
</select>
<!--提示块-->
<div id=div_hint style="font-size:12px;color:red;display:none;position:absolute; z-index:2; top:200;background-color: #F7F7F7; layer-background-color: # 0099FF; borda: 1px #9c9c9c sólido;filtro:Alpha(style=0,opacity=80,finishOpacity=100);"></div>
</corpo>
</Html>