大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> Script -> 可以编辑的Select

可以编辑的Select

时间: 2021-07-31 作者:daque

<script src="editableselect.js"></script><select id="editableselect"><option>不妨编纂的select第二版</option><option>bencalie创造</option></select>

=======================editableselect.js

window.onload=function(){ var objselect=editableselect var obj=document.all.editableselect gettop=obj.offsettop; getleft=obj.offsetleft; while(objselect=objselect.offsetparent){ gettop+=objselect.offsettop; getleft+=objselect.offsetleft; }

 var onewitem=document.createelement("object");  document.body.insertbefore(onewitem); onewitem.outerhtml="<object id=editable style=\"z-index:2;position:absolute\" type=\"text/x-scriptlet\" data=\"addin2.htm\"></object>";

 editable.style.left=getleft+1 editable.style.top=gettop+1 editable.style.width=obj.offsetwidth-19 editable.style.height=obj.offsetheight-3  obj.onchange=function(){editable.str(obj.options[obj.selectedindex].text)} obj.onresize=function(){editable.style.width=obj.offsetwidth-19}}

function addnewoption(value){ editableselect.options[editableselect.length]=new option(value,value) }

=======================addin2.htm

<script language="vbs">function public_str(thestrin) strin.value=thestrinend function</script><body leftmargin=0 topmargin=0><script language="javascript">function check(){var obj=parent.document.all.editableselectvar thevalue=document.all.strin.value.replace(/^\s*/g,"").replace(/\s*$/g,"")if(event.keycode==13){if(thevalue!=""){for(i=0;i<obj.length;i++) if(obj.options[i].text==thevalue){  alert("该选项仍旧生存!");  document.all.strin.focus();  document.all.strin.value="";  return; }parent.addnewoption(thevalue) }document.all.strin.value=""}}</script><input id=strin style='border:0;width:100%;height:100%;padding-top:2px' onkeydown=check()></body>

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.