时间:2021-07-01 10:21:17 帮助过:17人阅读
<body onload="init()">
<span id="id_select">
<s:select name="sjdwmc" list="sjdxdwList" listKey="dxbh" listValue="dwmc" headerKey="" headerValue=""></s:select>
</span>
</body>
如下是js代码,在init方法中调用selectReadOnly让下拉框变成只读。
代码如下:
/*根据页面上span的id设置select为只读/
function selectReadOnly(selectedId){
var obj = document.getElementById(selectedId);
obj.onmouseover = function(){
obj.setCapture();
}
obj.onmouseout = function(){
obj.releaseCapture();
}
obj.onfocus = function(){
obj.blur();
}
obj.onbeforeactivate = function(){
return false;
}
}
function init(){
selectReadOnly("id_select");
}
做到这里大功告成,试试效果吧!!!