如何设置Select下拉框的ReadOnly属性
因为Select下拉框只支持disabled属性,不支持readOnly属性,
而在提交时,disabled的控件,又是不提交值的,在网上搜索了一下,发现有个很好的方法:
Html代码
或者使用如下的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(){return false;}; obj.onfocus = function(){obj.blur();}; obj.onmouseover = function(){obj.setCapture();}; obj.onmouseout = function(){obj.releaseCapture();}; } } </script>
不过我这次用的是用一个隐藏控件传递disabled的select控件,因为这个select控件经常需要disable和enable 1 楼 jieping310 2012-04-18 正好需要这个呢,回去试试看