怎样用简洁的JS实现?
???????????
button.disabled=false/true;

解决方案 »

  1.   

    <html>
    <head>
    <title>无标题文档</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script language="javascript">
    function ChgStatus(src){
       var str=src.btnstatus;
       for(var i=0;i<btn.length;i++)
          str.charAt(i)==1?btn[i].disabled=false:btn[i].disabled=true;
    }
    </script>
    </head><body>
    <input name="btn" type="button" btnstatus="1001" onClick="ChgStatus(this)" value="Insert">
    <input name="btn" type="button" btnstatus="0101" onClick="ChgStatus(this)" value="Modify">
    <input name="btn" type="button" btnstatus="0011" onClick="ChgStatus(this)" value="Delete">
    <input name="btn" type="button" btnstatus="1111" onClick="ChgStatus(this)" value="Cancel">
    </body>
    </html>
    试试吧,一百个button也不怕
      

  2.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新建网页 2</title>
    </head><body><input type="button" value="insert" name="B1" onclick="B2.disabled='true';B3.disabled='true'">
    <input type="button" value="delete" name="B2" onclick="B1.disabled='true';B3.disabled='true'">
    <input type="button" value="modify" name="B3" onclick="B1.disabled='true';B2.disabled='true'">
    <input type="button" value="cancel" name="B4" onclick="B1.disabled='true';B2.disabled='true';B3.disabled='true';B4.disabled='true'"></body>
    </html>
      

  3.   

    zhaoxiaoyang(梅雪香) 
    写得非常好啊:)
      

  4.   

    <script language="javascript">
    <!--
      function fncchange(o1)
      {
        var o2 = document.getElementsByName('1');
        if(o1.id == '1')
        {
          for(var i=0;i<o2.length;i++)
          {
            if(o2[i].name != o1.name) o2[i].disabled = true;
          }
        }
        else
        {
          for(var i=0;i<o2.length;i++)
          {
            o2[i].disabled = false;
          }
        }
      }
    //-->
    </script><input type=button value=insert id=1 name=b1 onclick="fncchange(this)">
    <input type=button value=delete id=1 name=b2 onclick="fncchange(this)">
    <input type=button value=modify id=1 name=b3 onclick="fncchange(this)">
    <input type=button value=cancel id=2 name=b4 onclick="fncchange(this)">
      

  5.   

    zhaoxiaoyang(梅雪香)写得最简洁,这20分给你了,不过我还有个问题:btnstatus和btn.length是什么?能否解释一下!不胜感激
      

  6.   

    btnstatus是一个0,1字符串,0代表不可用,1代表可用
    btn.length btn是按钮控件的数组,.length就是按钮的个数