日期:2014-05-16  浏览次数:20390 次

请高手帮解答下,如何设置下拉列表不可选择
<select id="select-article-class"  name="articleClass" disabled="disabled" >
   <s:if test="#request.articleClassList!=null">
     <s:iterator value="#request.articleClassList">                   
        <option value="<s:property value="classId"/>">
          <s:property value="className" />
</option>
     </s:iterator >   
   </s:if>
</select>
<script type="text/javascript">

$('#select-article-class option').each(function(){
if($(this).val() == '<s:property value="#request.category.classId"/>'){  
$(this).attr('selected','selected');
}
});  
</script>
我的问题就是,要disable的效果, 但不是不可用,只是不能进行选择,因为这样我还能在后台得到值       
------最佳解决方案--------------------
用个浮动层盖住select不给操作就行了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<span style="position:relative">
<select><option value="1">1</option><option value="2">2</option><option value="3">3</option></select>
<div style="position:absolute;width:100%;height:100%;left:0px;top:0px;background:#fff;opacity:0;filter:alpha(opacity=0)">&nbsp;</div>
</span>

------其他解决方案--------------------
引用:
用个浮动层盖住select不给操作就行了
XML/HTML code?12345<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><span style="position:rel……

这么写之后,为什么整个页面里面可输入的地方都不能输入了
------其他解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function init(){
var a=document.getElementById("test");
var i=a.selectedIndex;
a.onchange=function(){
a.selectedIndex=i;
}
}
window.onload=init;
</script>
</head>

<body>
<select id="test">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</body>
</html>
大体这样试试
------其他解决方案--------------------
引用:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-……

这个我只需要把js那部分粘过去就可以么?
------其他解决方案--------------------