飛舞的幻想

          常用鏈接

          統計

          Google Adsense

          Zanox FWHX

          花個明白

          最新評論

          通過Iframe實現帶橫向滾動條的多選下拉框并且帶提示框

          主要思路:
          通過Iframe添加滾動條,在調用頁面使用Iframe實現滾動條,在iframe頁面里面實現多選select。通過主頁面將動態option傳遞給iframe的select實現下拉框。通過popup窗口的方式實現提示框。
          說明:調用頁面代碼里面還加了一個隱藏多選下拉框的目的是為了將值方便的傳遞以及保持相對較少的代碼改動(主要是修改實現)。
          調用頁面代碼:

          1. <select name=TMPFIELD size=9  style='width:160px;display:none;' multiple>  
          2. <%  
          3.    for(int opt5 =0;opt5<cols.size();opt5++){  
          4.      RepColsVo colVo =(RepColsVo) cols.get(opt5);  
          5. %>  
          6. <option title="<%=colVo.getRepColdis()%>" value="<%=colVo.getReportColid()%>"><%=colVo.getRepColdis()%></option>  
          7. <%}%>  
          8. </select>  
          9. <iframe name="iframeShowFields" src="<%=request.getContextPath()%>/jsp/include/iframeSelectReports.jsp"  id="iframeshow" allowTransparency="true"    style="z-index:0;height:150px;width:140px;" scrolling="auto">  
          10. </iframe>  

          Iframe頁面內容:
          1. <html>  
          2. <head>  
          3. <script language="javascript">  
          4.   var oP=window.createPopup();  
          5.   var globalobject;  
          6.   var oPopBody;  
          7.   function   showTip(_obj){  
          8.   globalobject=_obj;  
          9.   oPopBody= oP.document.body;  
          10.   line=parseInt(event.offsetY/15);  
          11.   if(globalobject.options.length>0){  
          12.   if(line>globalobject.options.length-1)  
          13.   {    
          14.       line=globalobject.options.length-1;   
          15.   }   
          16.   oPopBody.style.background="#fdfce9";   
          17.   oPopBody.style.border="solid black 1px";  
          18.   oPopBody.innerHTML="";  
          19.   var sText =globalobject.options[line].text;      
          20.   oPopBody.innerHTML='<div style="font-family:Arial;font-size:12px;">'+sText+'</div>';   
          21.   len=globalobject.options[line].text.length*10;  
          22.   oP.show(event.clientX+10,event.clientY+10,len, 20,document.body);  
          23.   }   
          24.  }  
          25.  function   hideTip(_obj){    
          26.   if(oP.isOpen){   
          27.     oP.hide();    
          28.    }  
          29.  }  
          30. function   addOption(){   
          31.     var   s=parent.document.frmdefine.TMPFIELD;  
          32.     var len=s.length;  
          33.     for(var i=0;i<len;i++)  
          34.     {  
          35.         var opt=document.createElement("OPTION");        
          36.         opt.text=s.options[i].text;    
          37.         opt.value=s.options[i].value;  
          38.         TMPFIELD.add(opt);  
          39.     }  
          40.        
          41.    
          42.  }  
          43.  </script>  
          44. </head>  
          45. <body bgcolor="#efefef" onload="addOption()">  
          46. <select  id="idtmpfield" onclick="showTip(this);" onmouseout="hideTip(this);" name="TMPFIELD" size=9   style="background-color:#efefef;width:auto;height:auto;border-width:0px;border-style:none;position:absolute;z-index:0;line-height:14px;border:none;clip:rect(0 95% 97% 0);margin-left:-13;margin-right:-50;margin-top:-19;margin-bottom:-40" multiple >  
          47. </select>  
          48. </body>  
          49. </html> 
          效果圖如下:



          posted on 2008-06-30 09:39 飛舞的幻想 閱讀(1840) 評論(0)  編輯  收藏 所屬分類: 生活感想


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 阳新县| 兴隆县| 元氏县| 拉萨市| 桓台县| 张家港市| 梅河口市| 天等县| 太仆寺旗| 宁明县| 霸州市| 长宁区| 海丰县| 平乡县| 新绛县| 淮滨县| 阳新县| 上林县| 隆安县| 兖州市| 稻城县| 天峨县| 汝阳县| 柘城县| 佛教| 顺义区| 瑞丽市| 金湖县| 阿拉善右旗| 和平县| 朔州市| 邛崃市| 平江县| 晋城| 东至县| 广汉市| 交口县| 肇州县| 桐柏县| 定结县| 昭苏县|