国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

為Html 的Select 加一個(gè)提示語和輸入方法

2019-11-18 19:40:25
字體:
供稿:網(wǎng)友

xieyj(原作)

<Html>
<Head>
<SCRipT LANGUAGE="javaScript">
<!--
//定義 select 原值
var oldValue,oldText;
//select下拉框的onkeydown事件,修改下拉框的值
function catch_keydown(sel)
{
 switch(event.keyCode)
 {
  case 13: //回車鍵
   event.returnValue = false;
   break;
  case 27: //Esc鍵
   sel.options[sel.selectedIndex].text = oldText;
   sel.options[sel.selectedIndex].value = oldValue;
   event.returnValue = false;
   break;
  case 8:  //空格健
   var s = sel.options[sel.selectedIndex].text;
   s = s.substr(0,s.length-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 = false;
   break;
 }
 if (!event.returnValue && sel.onchange)
  sel.onchange(sel)
}

//select下拉框的onkeyPRess事件,修改下拉框的值
function 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 = false;
 if (!event.returnValue && sel.onchange)
  sel.onchange(sel)
 }
}

//select下拉框的onfocus事件,保存下拉框原來的值
function catch_focus(sel) {
 oldText = sel.options[sel.selectedIndex].value;
 oldValue = sel.options[sel.selectedIndex].value;
}

//恢復(fù)select下拉列表當(dāng)前選中的值
function LoadSelect(obj,value)
{
 for (var i=0; i< obj.options.length; i++)
  if (obj.options[i].value == value)
  {
   obj.selectedIndex = i;
   break;
  }
}

//select 選擇框鼠標(biāo)上移時(shí)提示選擇的內(nèi)容
function selMouSEOver(obj)
{
 with (document.all.div_hint)
 {
  innerText = obj.options[obj.selectedIndex].text;
  if (innerText.length > 0)
  {
   innerText = " " + innerText + "  ";
   style.display = "block";
   style.left = event.clientX + 16;
   style.top = event.clientY;
  }
 }
}

//select 選擇框鼠標(biāo)移開時(shí)消失
function selMouseOut(obj)
{
 with (document.all.div_hint)
 {
  style.display = "none"
 }
}
//-->
</SCRIPT>
</Head>
<Body>
<!--調(diào)用-->
<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; border: 1px #9c9c9c solid;filter:Alpha(style=0,opacity=80,finishOpacity=100);"></div>
</Body>
</Html>

 

 


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 阿鲁科尔沁旗| 阜南县| 蛟河市| 阿鲁科尔沁旗| 阿鲁科尔沁旗| 青海省| 信丰县| 沭阳县| 松滋市| 新津县| 桦甸市| 隆化县| 昆山市| 林西县| 根河市| 梁山县| 嘉禾县| 秀山| 三门峡市| 堆龙德庆县| 宣化县| 大埔区| 岫岩| 蕉岭县| 竹山县| 乌拉特后旗| 秀山| 搜索| 团风县| 横山县| 上犹县| 田东县| 洛浦县| 巴彦淖尔市| 井冈山市| 象州县| 明星| 临沧市| 承德县| 海门市| 津南区|