我有一个页面上有 2个控件:一个asp.net的RadioButtonList控件,一个CheckBoxList控件。RadioButtonList控件的值:台式机和笔记本。 当点击 台式机 时,CheckBoxList可用,当点击 笔记本 时,CheckBoxList禁用。用javascript在客户端控件状态。初始状态时,选中 台式机,CheckBoxList 可用。直接进入页面时,状态可控,且正确。---------------------------------------------------------------------------------------------------------
现在我设置 笔记本 为初始状态,CheckBoxList禁用,并且这些状态保存到数据库。现在通过另一个页面点击更新刚刚保存到数据库中的记录,然后跳转到设置状态的页面。该页面加载的是数据库中的状态。即笔记本选中,CheckBoxList禁用。 现在我选中 台式机,想让 CheckBoxList可用。结果,CheckBoxList还是处于禁用状态。
-----------------------=---------------------------------------------------------------------------------------
跟踪javascript代码。能正确执行到判断当前选中的是 台式机,并且能 获得 CheckBoxList 是处于禁用状态,设置cbl.disabled=false;(cbl为CheckBoxList对象名),并且能读出 cbl.disabled的状态为false.但CheckBoxList控件却不可用。不知道为什么?
---------------------------------------------------------------------------------------------------------------
当初始状态为 台式机,CheckBoxList可用时,一切都可控。
--------------------------------------------------------一句话:就是设置控件的 disabled=false后,(设置后,能读出其disabled状态为false)控件仍处于禁用状态,为什么?
--------------------------function setSwitchTypeTextBox()
        {
            var rblCT= document.getElementById("RadioButtonListComputerType");//getElementById
            var rbs= rblCT.getElementsByTagName("INPUT"); 
            var rblMAC= document.getElementById("RadioButtonListMACConnected");//getElementById
            var _rbs= rblMAC.getElementsByTagName("INPUT");
            var txtST= document.getElementById("TextBoxSwitchType");
            var cblPCE = document.getElementById("CheckBoxListPCEquipment");
            
            if(!rblCT||!rbs||!rblMAC||!_rbs||!txtST||!cblPCE) return;
            
            for(var i=0;i<rbs.length;i++)
            {
              if(rbs[i].checked)
              {
                 if(rbs[i].value=='pc')//判断是台式机时,设置cblPCE.disabled=false,但状态仍禁用。                 {
                    isLaptop=false;
                    txtST.disabled=true;
                    txtST.value="没有笔记本电脑";  
                   if(cblPCE.disabled) 
                         alert('here');                 //2个alert都能执行到,并且读出正确状态。
                    cblPCE.disabled=false;  
                        alert(cblPCE.disabled)    
                 }
                 else
                 {  
                     isLaptop=true;
                     cblPCE.disabled=true;
                     for(var j=0;j<_rbs.length;j++)
                     {
                       if(_rbs[j].checked)
                       {
                          if(_rbs[j].value=='true')
                          {
                            txtST.disabled=false;
                            txtST.value="";
                          }
                          else
                          {
                            txtST.disabled=true;
                            txtST.value="笔记本电脑没有用无线接入网络";
                          }
                          break;
                       }  
                        
                     }         
                 }
                 break;    
              }   
            }
        }