1. <html>
  2.  
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  5. <title>EditSelect</title>
  6. <script>
  7. function isIE(){
  8. a=navigator.appVersion.split(";")
  9. b=a[].split(" ")
  10. return parseFloat(b[])
  11. }
  12.  
  13. if (isIE()<5.5)
  14. {
  15. scHTML='<div id="selectcontent" class="selectdiv" style="visibility:hidden;"><!--<iframe id=selframe frameborder=0 height=100%></iframe>--><div id="selecthtml" class="selectcontent">selectÁÐ表</div></div>'
  16. }
  17. else
  18. {
  19. scHTML='<div id="selectcontent" class="selectdiv" style="visibility:hidden;"><iframe id=selframe frameborder=0 height=100%></iframe><div id="selecthtml" class="selectcontent">selectÁÐ表</div></div>'
  20. }
  21.  
  22. document.write(scHTML)
  23. vDiv=selectcontent
  24. vDivHtml=selecthtml
  25.  
  26. function editselect(name,size,defaulttext,width,height,readonly){
  27. var combo=this;
  28. this.options=new Array();
  29. this.oj=new Array();
  30. this.name=name;
  31. this.divname=name+'_div';
  32. this.buttonname=name+'_button';
  33. this.tablename=name+'_table';
  34. this.htmltable=name+'_html'
  35. if (!height) this.height=; else this.height=height
  36. if (width) this.width=width
  37. if (!size) size=
  38. if (!defaulttext) defaulttext=""
  39. if (!readonly || readonly==) {readonly="" }else {if (readonly==) readonly="readonly style=cursor:default";this.readonly=}
  40.  
  41. esHTML='<div id='+this.divname+'>'
  42. +'<table id='+this.tablename+' cellpadding=0 cellspacing=0 class=select><tr><td bgcolor=#FFFFFF>'
  43. +'<input type=text class=selecttext size="'+size+'" name='+name+' value="'+defaulttext+'" '+readonly+'><td><button class=selectbutton id='+this.buttonname+'>6</td></tr></table>'
  44. +'</div>'
  45. document.write(esHTML)
  46. this.sbutton=eval("document.all."+this.buttonname)
  47.  
  48. if (this.readonly==) eval("document.all."+this.name).onclick=function(){combo.show()}
  49.  
  50. this.sbutton.onclick=function(){combo.show()}
  51. this.show=function(){
  52. pDiv=eval(combo.divname)
  53. pTable=eval(combo.tablename)
  54. var vHTML='<table id=htmltable cellspacing="0" cellpadding="2" bgcolor="#ffffff" class="selecttable" width=100%>'
  55. for (i=;i<combo.options.length;i++)
  56. {
  57. vHTML+='<tr onmouseover="mo(this)" onmouseout="mu(this)" onclick="document.all.'+combo.name+'.value=this.innerText;selectcontent.style.visibility=\'hidden\';'+combo.oj[i]+'"><td nowrap>'+combo.options[i]
  58. }
  59. vHTML+="</table>"
  60. vDivHtml.innerHTML=vHTML
  61.  
  62. vtop=pDiv.offsetTop+pDiv.offsetHeight
  63. vleft=pDiv.offsetLeft+
  64.  
  65. vParent = pDiv.offsetParent;
  66. while (vParent.tagName.toUpperCase() != "BODY")
  67. {
  68. vleft += vParent.offsetLeft;
  69. vtop += vParent.offsetTop;
  70. vParent = vParent.offsetParent;
  71. }
  72.  
  73. var redge=document.body.clientWidth-vleft
  74. var bedge=document.body.clientHeight-vtop
  75.  
  76. if (!combo.width) {vDiv.style.width=pTable.offsetWidth} else {vDiv.style.width=combo.width}
  77.  
  78. if (combo.height==)
  79. {
  80. vDiv.style.pixelHeight=parseInt(htmltable.offsetHeight)+
  81. vDivHtml.style.pixelHeight=parseInt(htmltable.offsetHeight)+
  82. }
  83. else
  84. {
  85. if (htmltable.offsetHeight>combo.height)
  86. {
  87. vDiv.style.pixelHeight=combo.height
  88. vDivHtml.style.pixelHeight=combo.height
  89.  
  90. }
  91. else
  92. {
  93.  
  94. vDiv.style.pixelHeight=parseInt(htmltable.offsetHeight)+
  95. vDivHtml.style.pixelHeight=parseInt(htmltable.offsetHeight)+
  96. }
  97.  
  98. }
  99.  
  100. vDivHtml.scrollTop=
  101.  
  102. if (redge<vDiv.offsetWidth)
  103. vDiv.style.left=vleft--(vDiv.offsetWidth-redge)
  104. else
  105. vDiv.style.left=vleft-
  106.  
  107. if (bedge<vDiv.offsetHeight)
  108. //vDiv.style.top=vtop-vDiv.offsetHeight-pDiv.offsetHeight
  109. vDiv.style.top=vtop-vDiv.offsetHeight+bedge
  110. else
  111. vDiv.style.top=vtop
  112.  
  113. vDivHtml.style.width=parseInt(vDiv.style.width)
  114. vDiv.style.visibility="visible"
  115. }
  116.  
  117. this.add=function(text,js){
  118. combo.options[combo.options.length]=text
  119. combo.oj[combo.oj.length]=js
  120.  
  121. }
  122.  
  123. this.clearall=function(){
  124. combo.options=new Array()
  125. }
  126.  
  127. this.about=function(){
  128.  
  129. }
  130. }
  131.  
  132. function mo(obj){
  133. obj.style.backgroundColor="#000099"
  134. obj.style.color="#ffffff"
  135. }
  136.  
  137. function mu(obj){
  138. obj.style.backgroundColor=""
  139. obj.style.color="#000000"
  140. }
  141.  
  142. document.onmousedown=function(){
  143. if (vDiv.style.visibility=="visible"){
  144. mx=event.x + document.body.scrollLeft
  145. my=event.y + document.body.scrollTop;
  146.  
  147. x1=vDiv.offsetLeft
  148. y1=vDiv.offsetTop
  149.  
  150. x2=vDiv.offsetLeft+vDiv.offsetWidth
  151. y2=vDiv.offsetTop+vDiv.offsetHeight
  152.  
  153. if (mx<x1 || my<y1 || x2<mx || y2<my)
  154. {
  155. vDiv.style.visibility='hidden'
  156. }
  157. }
  158. }</script>
  159.  
  160. <style>
  161. .selecttext{
  162. border:0px
  163. height: ;
  164. font-family:arial;
  165. font-size:12px;
  166. }
  167. .selectbutton{
  168. font-family:webdings;
  169. font-size:10px;
  170. height: ;
  171. width: ;
  172. border:1px solid #83A5EB;
  173. line-height:0px;
  174. padding-bottom:3px;
  175. background-color:#D1E0FD
  176. }
  177. .selecttable{
  178. font-family:arial;
  179. font-size:12px;
  180. cursor:default;
  181. }
  182. .selectcontent
  183. {
  184. position: absolute;
  185. top:;
  186. left:;
  187. overflow:auto;
  188. border:1px solid #
  189. }
  190.  
  191. .selectdiv
  192. {
  193. position: absolute;
  194. width:;
  195. overflow:hidden;
  196. }
  197. .select{
  198. border-collapse: collapse;
  199. border:1px solid #7F9DB9
  200. }
  201. </style>
  202. </head>
  203.  
  204. <body bgcolor="#83A5EB">
  205.  
  206. <table border="" width="100%">
  207. <tr>
  208. <td width="" align="center"><font size="">可编辑的Select</font></td>
  209. <td><script>
  210. var sel1=new editselect("select1","","可编辑的Select","");
  211. sel1.add("这是一个可以编辑的Select")
  212. sel1.add("支持CSS")
  213. sel1.add("可以通过CSS,修改外形")
  214. sel1.add("突破原来的Select诸多限制")
  215. </script></td>
  216. </tr>
  217. <tr>
  218. <td width="" align="center"><font size="">长度可以随意修改
  219. 可以设置为只读</font></td>
  220. <td>
  221. <script>
  222. var sel2=new editselect("select2","","长度可以随意修改",,,);
  223. sel2.add("这是一个可以编辑的Select")
  224. sel2.add("支持CSS")
  225. sel2.add("可以通过CSS,修改外形")
  226.  
  227. sel2.add("作者:舜子制作")
  228. sel2.add("MSN:puterjam@msn.com")
  229. </script>
  230. </td>
  231. </tr>
  232. <tr>
  233. <td width="" align="center"><font size="">可以遮盖系统Select</font></td>
  234. <td>
  235. <script>
  236. var sel3=new editselect("select3","","可以遮盖系统Select","",);
  237. sel3.add("这是一个可以编辑的Select")
  238. sel3.add("支持CSS")
  239. sel3.add("可以通过CSS,修改外形")
  240. sel3.add("突破原来的Select诸多限制")
  241. </script>
  242. </td>
  243. </tr>
  244. <tr>
  245. <td width="" align="right"> </td>
  246. <td><select><option>系统的Select</option></select> </td>
  247. </tr>
  248. </table>
  249. </body>
  250.  
  251. </html>

http://www.jb51.net/article/914.htm

可编辑select的更多相关文章

  1. 可编辑的select框的实现(实用版)

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML>  <HEA ...

  2. jquery实现可编辑的下拉框( input + select )

    HTML: <input id="inputModel" /> <select name="EngineModel" size="1 ...

  3. select()

    select(),确定一个或多个套接口的状态,本函数用于确定一个或多个套接口的状态,对每一个套接口,调用者可查询它的可读性.可写性及错误状态信息,用fd_set结构来表示一组等待检查的套接口,在调用返 ...

  4. js,JQuery实现,带筛选,搜索的select

    代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title& ...

  5. jqgrid 实现行编辑,表单编辑的列联动

    这个问题的场景相信大家都遇到过,比方有A,B,C三列,B,C列均为下拉框.可是C列的值是由B列的值来决定的.即C列中的值是动态变化的,变化的根据就是B列中你选择的值. 本文给出的是一个有用,简易快捷的 ...

  6. 你想的到想不到的 javascript 应用小技巧方法

    javascript 在前端应用体验小技巧继续积累. 事件源对象 event.srcElement.tagName event.srcElement.type 捕获释放 event.srcElemen ...

  7. javascript小技巧

    事件源对象 event.srcElement.tagName event.srcElement.type 捕获释放 event.srcElement.setCapture();  event.srcE ...

  8. JS详解

    事件源对象:event.srcElement.tagName  event.srcElement.type 捕获/释放:event.srcElement.setCapture();  event.sr ...

  9. JS技术大全

    事件源对象:event.srcElement.tagName  event.srcElement.type 捕获/释放:event.srcElement.setCapture();  event.sr ...

随机推荐

  1. Uva1398 Meteor

    扫描线法. 将流星出现在相机里的时间转化成线段,离散化端点后,扫描何时出现的流星最多.注意边界的不算,所以要先减右端点再加左端点 /*By SilverN*/ #include<iostream ...

  2. windows核心编程读后感(待续)

    自从大一读那本超厚的C程序设计以后,从来没有像这样慢慢地读一本书了.windows核心这本书足足看了2个多星期.一张张慢慢看,做笔记.感觉学到了很多基础的知识,关于内核方面的没有啥可以做实验的,都在看 ...

  3. cantor三分集

    值得一提的是,第一次听说cantor三分集是在数字电路课上,然而数电是我最不喜欢的课程之一...... 分形大都具有自相似.自仿射性质,所以cantor三分集用递归再合适不过了,本来不想用matlab ...

  4. xpath中/和//的差别

    xpath中 "/"是在子节点中查找,"//"是在所有子节点中查找,包括子节点的子节点. example: leve1/leve2:得到文本leve2 leve ...

  5. 深入理解JavaScript中创建对象模式的演变(原型)

    深入理解JavaScript中创建对象模式的演变(原型) 创建对象的模式多种多样,但是各种模式又有怎样的利弊呢?有没有一种最为完美的模式呢?下面我将就以下几个方面来分析创建对象的几种模式: Objec ...

  6. 远程连接实验室的VPN

    Windows 7 (win8类似)的用户请按以下步骤进行操作:1.点击“开始”菜单,然后点击“控制面板”,然后点击“查看网络和任务”.2.点击“设置新连接或网络”.3.点击“连接到工作区”,然后点击 ...

  7. try throw catch

    #include "stdafx.h" #include <iostream> #include <stdlib.h> using namespace st ...

  8. WinForm------分页控件dll下载地址

    转载: http://files.cnblogs.com/wuhuacong/TestPager_SqlLite.rar

  9. 对Java垃圾回收最大的误解是什么

    当 我还是小孩的时候,父母常说如果你不好好学习,就只能去扫大街了.但他们不知道的是,清理垃圾实际上是很棒的一件事.可能这也是即使在Java的世界中, 同样有很多开发者对GC算法产生误解的原因--包括它 ...

  10. UIView UIwindow

    UI:用户界面,用户能看到的各种各样的页面元素 UIview :代表屏幕上的一个矩形区域,管理界面上的内容       创建UIview 1.开辟空间并初始化视图(初始化时,给出视图位置和大小 2.对 ...