我有一个页面上有 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;
}
}
}
现在我设置 笔记本 为初始状态,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;
}
}
}
解决方案 »
- 关于jwplayer网页播放器连续播放的问题
- if (e.stopPropagation) {e.stopPropagation();}
- 在<div>中如何引用JavaScript变量 (给错分帖)
- 这代码如何在javascript里运行?
- 帮我看看这段js代码,实现ajax drag and drop的
- 那位大哥有空,请帮小弟解决一个打印问题
- js问题,iframe子页面调用父页面中onload中的方法问题
- 屏蔽CTRL+N的问题
- 求救表单的验证。。。(在线等待)
- 怎么做一个可以在IFRAME里面查找指定字符并替换全部的功能? 跪谢~~~~
- 如何获得表格的tr元素和当前行的行号
- 如何用js语句给下面<table>的<tr id="t3"> <td>333 </td> </tr> 做一个超链接
http://www.woshixiaoqiang.com.cn/archives/74.html