当前位置: 首页 > 图文教程 > 网络编程 > ASP > 为Html 的Select 加一个提示语和输入方法

ASP
看人家用使用InstallShield制作ASP安装程序(5)
看人家用使用InstallShield制作ASP安装程序(4)
看人家用使用InstallShield制作ASP安装程序(3)
看人家用使用InstallShield制作ASP安装程序(2)
看人家用使用InstallShield制作ASP安装程序(1)
取得浏览者的离开时间
base64编码、解码函数
动态显示图片的函数(显示广告条)
发送带附件的HTML格式邮件例程可以带附件
一种在父窗口中得知window.open()出的子窗口关闭事件的方法
一个老个写的无组件上传
避免asp的SQL的执行效率低
树型结构在ASP中的简单解决
无需数据库循环的无级分类代码
检查字符串strSource是否为big或big5码
有关重复记录的删除(SQL SERVER)
WINDOWS2000服务器账号登陆身份验证
使用VC++6.0制作ASP服务器控件简介
利用sql的存储过程实现dos命令的asp程序
WSH 直接将查询数据结果生成 EXCEL 表

ASP 中的 为Html 的Select 加一个提示语和输入方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 59 ::
收藏到网摘: n/a

       <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;
  }
  
  //恢复select下拉列表当前选中的值
  function LoadSelect(obj,value)
  {
   for (var i=0; i< obj.options.length; i++)
   if (obj.options[i].value == value)
   {
   obj.selectedIndex = i;
   break;
   }
  }
  
  //select 选择框鼠标上移时提示选择的内容
  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 选择框鼠标移开时消失
  function selMouseOut(obj)
  {
   with (document.all.div_hint)
   {
   style.display = "none"
   }
  }
  //-->
  </SCRIPT>
  </Head>
  <Body>
  <!--调用-->
  <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-c"