本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/youbl/archive/2009/02/27/3942578.aspx
因为Select下拉框只支持disabled属性,不支持readOnly属性,
而在提交时,disabled的控件,又是不提交值的,在网上搜索了一下,发现有个很好的方法:
<selectname="select123"onbeforeactivate="return false;"onfocus="this.blur();"onmouseover="this.setCapture();"onmouseover="this.releaseCapture();">
<option>aaa</option>
</select>
或者使用如下的js脚本:
<select name="select123">
<option>aaa</option>
</select>
<script type="text/javascript">
SetReadOnly(document.getElementById("select123"));
function SetReadOnly(obj){
if(obj){
obj.onbeforeactivate = function(){returnfalse;};
obj.onfocus = function(){obj.blur();};
obj. = function(){obj.setCapture();};
obj. = function(){obj.releaseCapture();};
}
}
</script>
嘿嘿 如果以上分享对你有用,烦请浏览下在下的小店:http://51shoujike.taobao.com
转载于:https://blog.51cto.com/dy123/664360