您的位置:首页 > 其它

Select下拉框的只读属性设置

2011-09-14 14:50 330 查看
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/youbl/archive/2009/02/27/3942578.aspx

因为Select下拉框只支持disabled属性,不支持readOnly属性,而在提交时,disabled的控件,又是不提交值的,在网上搜索了一下,发现有个很好的方法:Html代码

<selectname="select123"onbeforeactivate="return false;"onfocus="this.blur();"onmouseover="this.setCapture();"onmouseover="this.releaseCapture();">

<option>aaa</option>

</select>

或者使用如下的js脚本: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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: