急救!!!我想让页面一加载时Table中的内容均为只读?点击按钮后改为可编辑望高手指点

解决方案 »

  1.   

    Foreach Table所有控件 设置readonly属性
      

  2.   

    <input type="text" value="sdf" />
    <table border="1" id="ss" borad="1">
    <tr><td><input type="text" value="sdf"></td></tr>
    <tr><td><input type="text" value="sdf"></td></tr>
    </table>
    <input type="button" value="编辑table" onclick="set_disabled(false)"/>
    <input type="button" value="锁定table" onclick="set_disabled(true)"/>
    <script language="javascript">
    function set_disabled(boolean){
    var es=document.getElementById("ss").all;
    for(i=0;i<es.length;i++){
    es[i].disabled=boolean
    }
    }
    set_disabled(true);</script>
      

  3.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>  
        <script type="text/javascript">
            function setDisabled(bo) {
                $("#table1 :input").attr("disabled",bo);
            }
        </script>
    </head>
    <body>
        <input id="Button1" type="button" value="启用" onclick="setDisabled(false)" />
        <input id="Button2" type="button" value="禁用" onclick="setDisabled(true)" />
        <table id="table1" >
            <tr>
                <td>
                    <input id="Text1" type="text" />
                </td>
                <td>
                    <input id="Password1" type="password" />
                </td>
            </tr>
            <tr>
                <td>
                    <select id="Select1">
                        <option>1</option>
                    </select>
                </td>
                <td>
                    <input id="Checkbox1" type="checkbox" />
                    <input id="Radio1" type="radio" />
                </td>
            </tr>
            <tr>
                <td>
                    <input id="File1" type="file" />
                </td>
                <td>
                    <textarea id="TextArea1" cols="20" rows="2"></textarea>
                </td>
            </tr>
        </table>
    </body>
    </html>