HTML控件的disabled = true 可以把该控件设置成不可用的状态;document.getElementsByTagName("input")可以遍历页面上的所有<input>控件,之后就自己发挥吧,应该够用了

解决方案 »

  1.   

    <!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">
    <!-- DW6 -->
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>shawl.qiu template</title></script>
    <script type="text/javascript">
    //<![CDATA[
    function test(obj){
    for(var i=0; i<obj.length; i++){
    for(var j=0; j<obj[i].length; j++){
    obj[i][j].disabled=true;
    }
    }
    }
    //]]>
    </script>
    </head>
    <body>
    <form name="form1" id="form1" method="post" action="">
      <p>
        <input type="text" name="textfield" />
        <br />
        <input type="checkbox" name="checkbox" value="checkbox" />
        <input type="checkbox" name="checkbox" value="checkbox" />
        <input type="checkbox" name="checkbox" value="checkbox" />
        <br />
        <input name="radiobutton" type="radio" value="radiobutton" />
        <input name="radiobutton" type="radio" value="radiobutton" />
        <input name="radiobutton" type="radio" value="radiobutton" />
        <br />
        <textarea name="textarea"></textarea>
        <br />
        <input type="submit" name="Submit" value="Submit" />
        <input type="button" name="Button" value="Button" />
      </p>
    </form>
    <form name="form2" id="form2" method="post" action="">
      <p>
        <input type="text" name="textfield" />
        <br />
        <input type="checkbox" name="checkbox" value="checkbox" />
        <input type="checkbox" name="checkbox" value="checkbox" />
        <input type="checkbox" name="checkbox" value="checkbox" />
        <br />
        <input name="radiobutton" type="radio" value="radiobutton" />
        <input name="radiobutton" type="radio" value="radiobutton" />
        <input name="radiobutton" type="radio" value="radiobutton" />
        <br />
        <textarea name="textarea"></textarea>
        <br />
        <input type="submit" name="Submit" value="Submit"  />
        <input type="button" name="Button" value="Button" />
      </p>
    </form><button onclick="test(document.forms)">控件不可用</button>
    </body>
    </html>
      

  2.   

    <!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">
    <!-- DW6 -->
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>shawl.qiu template</title></script>
    <script type="text/javascript">
    //<![CDATA[
    function fFmDsabComp(obj){
    for(var i=0; i<obj.length; i++){
    for(var j=0; j<obj[i].length; j++){
    switch(obj[i][j].id){
    case 'tbx': break;
    case 'tbx1': break;
    case 'txa': break;
    case 'txa1': break;
    default: obj[i][j].disabled=true;
    }
    }
    }
    }
    //]]>
    </script>
    </head>
    <body>
    <form name="form1" id="form1" method="post" action="">
      <p>
        <input type="text" name="textfield"  id="tbx"/>
        <br />
        <input type="checkbox" name="checkbox" value="checkbox" />
        <input type="checkbox" name="checkbox" value="checkbox" />
        <input type="checkbox" name="checkbox" value="checkbox" />
        <br />
        <input name="radiobutton" type="radio" value="radiobutton" />
        <input name="radiobutton" type="radio" value="radiobutton" />
        <input name="radiobutton" type="radio" value="radiobutton" />
        <br />
        <textarea name="textarea"></textarea>
        <br />
        <input type="submit" name="Submit" value="Submit" />
        <input type="button" name="Button" value="Button" />
      </p>
    </form>
    <form name="form2" id="form2" method="post" action="">
      <p>
        <input type="text" name="textfield" id="tbx1" />
        <br />
        <input type="checkbox" name="checkbox" value="checkbox" />
        <input type="checkbox" name="checkbox" value="checkbox" />
        <input type="checkbox" name="checkbox" value="checkbox" />
        <br />
        <input name="radiobutton" type="radio" value="radiobutton" />
        <input name="radiobutton" type="radio" value="radiobutton" />
        <input name="radiobutton" type="radio" value="radiobutton" />
        <br />
        <textarea name="textarea" id="txa1"></textarea>
        <br />
        <input type="submit" name="Submit" value="Submit"  />
        <input type="button" name="Button" value="Button" />
      </p>
    </form>
    <button onclick="fFmDsabComp(document.forms)">控件不可用</button>
    </body>
    </html>