我的页面中有好多个select,其中有一些设置了disabled=true属性,为了能够使select的值能够提交,我在js中用了下面的代码重新设置了一次    
if($('select').attr("disabled")==true){
           $('select').attr("disabled",false)
    }
可是问题是这样一来,页面上所有的select元素在提交之后都变成了可以选择的了,
有没有方法效果是和 disabled一样,但是能够提交数值的。
请各位大虾帮我解答一下,万谢!

解决方案 »

  1.   

    disabled 是不可获焦,不可接收数据,readonly 可以获焦,可以接收数据
      

  2.   

    disable了就不能获得其value了?
    再说 提交完了 你再把它置灰掉也可以啊
      

  3.   

    把disabled改成readonly就行了,这种情况就该用readonly。
      

  4.   

    你可以用<s:hidden id="" name=""></s:hidden>得到至灰色那个下拉select中的值,在传给后台
      

  5.   


    <!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">
    <body>
    <select id="selList" onchange="setVal()">
        <option value="1" >1</option>
        <option value="2" selected="selected">2</option>
    </select>
    <input id="hdSelList" type="text" />
    <script type="text/javascript">
        //本demo是为了清晰地表达, 你在select中加入 disabled="disabled",
        //将input中的type改为hidden即为你要的效果了.
        //提交时, 你不要取selList的值, 取hdSelList的值就好了.    setVal();  //1.在初始加载时就将两者的值设置为一致;
        //2. 为了防止代码以后会有改动---有时不需要disabled, 故有上面的onchange="setVal()"
        function setVal() {
            document.getElementById('hdSelList').value = document.getElementById('selList').value;
        }
    </script>
    </body>
    </html>
      

  6.   


    <!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>
    <script src="../ec/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script type="text/javascript" >
        function commit() {
            $DisSelects = $("select[disabled='disabled']");//获取所有被禁用的select
            $DisSelects.attr("disabled", false); //处理之前, 全部打开
            $("#form1").submit();                //提交
            $DisSelects.attr("disabled", true);  //处理完成, 全部禁用
        }
    </script>    
    </head>
    <body>
    <form id="form1" action="HTMLPage.htm">
        <input type="button" value="submit" onclick="commit()" />
        <select id="Select1" disabled="disabled" >
            <option value="0" >0</option>
            <option value="1" selected="selected">1</option>
        </select>
        <select id="Select2" disabled="disabled" >
            <option value="1" >1</option>
            <option value="2" selected="selected">2</option>
        </select>
        <select id="Select3" disabled="disabled" >
            <option value="2" >2</option>
            <option value="3" selected="selected">3</option>
        </select>
        <select id="Select4"  disabled="disabled" >
            <option value="3" >3</option>
            <option value="4" selected="selected">4</option>
        </select>
    </form>
    </body>
    </html>上面的也就两三行的代码, 处理的时间很长吗?