<script>
function EditSelect(ThisForm){    var FormSelect = document.getElementById(ThisForm).getElementsByTagName("select");
  for(is=0;is<FormSelect.length;is++)
  {
      if(FormSelect[is].disabled==true)
    {
   FormSelect[is].disabled=false;
}
  else
    {
   FormSelect[is].disabled=true;
}
  }
  

</script>
<h5>怎么实现点击其中一个修改按钮时候,其他表单内的select自动禁用?</h1><form id="test1" name="test1">
表单列表
<select size=1 name=slt disabled> 
<option>1</option> 
<option>2</option> 
</select> 
表单列表
<select size=1 name=AAt disabled> 
<option>3</option> 
<option>4</option> 
</select> 
<input type="button" name="button4" value="修改" onclick="EditSelect('test1');" />
</form>
<br />第二个form
<form id="test2" name="test2">
表单列表
<select size=1 name=slt disabled> 
<option>5</option> 
<option>6</option> 
</select> 
表单列表
<select size=1 name=AAt disabled> 
<option>7</option> 
<option>8</option> 
</select> 
<input type="button" name="button4" value="修改" onclick="EditSelect('test2');" />
</form>
<br />第三个form
<form id="test3" name="test2">
表单列表
<select size=1 name=slt disabled> 
<option>9</option> 
<option>10</option> 
</select> 
表单列表
<select size=1 name=AAt disabled> 
<option>11</option> 
<option>12</option> 
</select> 
<input type="button" name="button4" value="修改" onclick="EditSelect('test3');" />
</form>select函数

解决方案 »

  1.   

    你的示例好用呀?你想点一个按钮,所有select都禁用?
      

  2.   


    能不能把其他的form里面的select也一道给关了?
    我的思路是先把所有已经激活的select先都给关了
    然后在执行激活指定的form里面的select
      

  3.   


    能不能把其他的form里面的select也一道给关了?
    我的思路是先把所有已经激活的select先都给关了
    然后在执行激活指定的form里面的select
    function EditSelect(ThisForm){
    var FormSelect =(document.getElementById(ThisForm) === null) ?document.getElementsByTagName("select"):document.getElementById(ThisForm).getElementsByTagName("select");
    //...
    }
      

  4.   

    <input type="button" name="button4" value="全局切换" onclick="EditSelect('body');" />
      

  5.   

    呀! 你这个更牛啊!佩服佩服!不过 我是想实现激活其中一个select时候,其他的select(就算已经激活或者本身没有激活的)都自动禁用,防止出现多个select被激活而需要一个一个去关闭你这个代码牛X,我可以实现全部关闭掉!佩服佩服!!能不能再给点代码吗?弄到这里我实在不知道怎么弄了。感谢感谢!!
      

  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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script>
    function EditSelect(ThisForm){  
    //  alert(document.getElementById(ThisForm) === null) ;
      var FormSelect =(document.getElementById(ThisForm) === null) ?document.getElementsByTagName("select"):document.getElementById(ThisForm).getElementsByTagName("select");
      for(is=0;is<FormSelect.length;is++)  {
        if(FormSelect[is].disabled==true){
        FormSelect[is].disabled=false;
    }else{
        FormSelect[is].disabled=true;
    }
      }

    function singleActivation(selectName){
    var allSelect = document.getElementsByTagName("select");
    for(is=0;is<allSelect.length;is++)  {
         if(allSelect[is].name == selectName) continue;
       
    if(allSelect[is].disabled != true){
        allSelect[is].disabled=true;
    }
    }
    }
    </script>
    </head>
    <body>
    <h5>怎么实现点击其中一个修改按钮时候,其他表单内的select自动禁用?</h1><form id="test1" name="test1">
    表单列表
    <select size="1" name="slt"> 
    <option>1</option> 
    <option>2</option> 
    </select> 
    表单列表
    <select size="1" name="AAt"> 
    <option>3</option> 
    <option>4</option> 
    </select> 
    <input type="button" name="button4" value="修改" onclick="EditSelect('test1');" />
    </form>
    <br />第二个form
    <form id="test2" name="test2">
    表单列表
    <select size="1" name="slr"> 
    <option>5</option> 
    <option>6</option> 
    </select> 
    表单列表
    <select size="1" name="AAr"> 
    <option>7</option> 
    <option>8</option> 
    </select> 
    <input type="button" name="button4" value="修改" onclick="EditSelect('test2');" />
    </form>
    <br />第三个form
    <form id="test3" name="test2">
    表单列表
    <select size="1" name="slg"> 
    <option>9</option> 
    <option>10</option> 
    </select> 
    表单列表
    <select size="1" name="AAg"> 
    <option>11</option> 
    <option>12</option> 
    </select> 
    <input type="button" name="button4" value="修改" onclick="EditSelect('test3');" />
    </form><input type="button" name="button4" value="全局切换" onclick="EditSelect('body');" />
    <input type="text" id="sigleSelectName" value="AAr" />
    <input type="button" name="button5" value="单体激活" onclick="singleActivation(document.getElementById('sigleSelectName').value);" />
    </body>
    </html>
      

  7.   

    实在抱歉!看到你的代码一直在忙今晚略做修改 竟然可以达到想要的目的了!感激不尽!!请兄台顺便看看代码是不是可以更精简些?我拿你的源代码瞎胡参合的。。拜谢!<!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>
    function singleActivation(ThisForm){
    var allSelect = document.getElementsByTagName("select");
    for(is=0;is<allSelect.length;is++)  {
         if(allSelect[is].name == ThisForm) continue;
       
    if(allSelect[is].disabled != true){
        allSelect[is].disabled=true;
    }
    }
    var FormSelect = document.getElementById(ThisForm).getElementsByTagName("select");
    for(i=0;i<FormSelect.length;i++)  {
            if(FormSelect[i].disabled==true){
           FormSelect[i].disabled=false;
        }else{
           FormSelect[i].disabled=true;
        }
    }}
    </script>
    </head>
    <body>
    <h5>是不是可以更精简一些?</h1><form id="test1" name="test1">
    表单列表
    <select size="1" name="slt"> 
    <option>1</option> 
    <option>2</option> 
    </select> 
    表单列表
    <select size="1" name="AAt"> 
    <option>3</option> 
    <option>4</option> 
    </select> 
    <input type="button" name="button4" value="修改" onclick="singleActivation('test1','test1')" />
    </form>
    <br />第二个form
    <form id="test2" name="test2">
    表单列表
    <select size="1" name="slr"> 
    <option>5</option> 
    <option>6</option> 
    </select> 
    表单列表
    <select size="1" name="AAr"> 
    <option>7</option> 
    <option>8</option> 
    </select> 
    <input type="button" name="button4" value="修改" onclick="singleActivation('test2','test2')" />
    </form>
    <br />第三个form
    <form id="test3" name="test2">
    表单列表
    <select size="1" name="slg"> 
    <option>9</option> 
    <option>10</option> 
    </select> 
    表单列表
    <select size="1" name="AAg"> 
    <option>11</option> 
    <option>12</option> 
    </select> 
    <input type="button" name="button4" value="修改" onclick="singleActivation('test3','test3')" />
    </form></body>
    </html>