本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/youbl/archive/2009/02/27/3942578.aspx


因为Select下拉框只支持disabled属性,不支持readOnly属性,

而在提交时,disabled的控件,又是不提交值的,在网上搜索了一下,发现有个很好的方法:

Html代码 收藏代码
  1. <selectname="select123"onbeforeactivate="return false;"onfocus="this.blur();"onmouseover="this.setCapture();"onmouseover="this.releaseCapture();">

  2. <option>aaa</option>

  3. </select>


或者使用如下的js脚本:

Js代码 收藏代码
  1. <select name="select123">  

  2.    <option>aaa</option>  

  3. </select>  

  4. <script type="text/javascript">  

  5. SetReadOnly(document.getElementById("select123"));  

  6. function SetReadOnly(obj){  

  7. if(obj){  

  8.        obj.onbeforeactivate = function(){returnfalse;};  

  9.        obj.onfocus = function(){obj.blur();};  

  10.        obj. = function(){obj.setCapture();};  

  11.        obj. = function(){obj.releaseCapture();};  

  12.    }  

  13. }  

  14. </script>  

嘿嘿  如果以上分享对你有用,烦请浏览下在下的小店:http://51shoujike.taobao.com