使用javascript启用/禁用复选框时出现问题

时间:2011-04-13 07:22:25

标签: javascript asp.net

我的问题是在javascript中启用了一个复选框,但在禁用我的代码时运行正常..我已经更改chk1.enabled =已检查但是它无法正常运行..

这是我的代码:

<script language="javascript" type="text/javascript">

    function ckGrp(){

    var ck_arr = document.getElementsByName('chkRaps');
    var ck = document.getElementsByName('chkPPS');
    if(ck.checked == true){
           ck_arr.disabled = true;
    }else{
          ck_arr.disabled = false;
            }

    }

   </script>

asp.net代码:

<td><asp:CheckBox OnClick="ckGrp(); " ID="chkPPS" runat="server" /> &nbsp;<asp:Label ID="Label2" 
        runat="server" Text="Bill Under PPS"></asp:Label>


  <td><asp:CheckBox ID="chkRaps" runat="server" ClientIDMode="Static" Enabled="False" /> &nbsp;<asp:Label ID="Label3" 
        runat="server" Text="Include first billable visit for RAPs"></asp:Label><br/>
        <asp:CheckBox ID="chkTarNumber" runat="server" ClientIDMode="Static" Enabled="False"/> &nbsp;<asp:Label ID="Label4" 
        runat="server" Text="Use Claim Oasis Matching Key as TAR Number"></asp:Label><br/>
        <asp:CheckBox ID="chkPPSMedthod" runat="server" ClientIDMode="Static" Enabled="False" /> &nbsp;<asp:Label ID="Label5" 
        runat="server" Text="Effective 01/01/08 use new PPS Payment Method"></asp:Label><br/>
        <asp:CheckBox ID="chkMTP" runat="server" ClientIDMode="Static" Enabled="False" /> &nbsp;<asp:Label ID="Label6" 
        runat="server" Text="Auto Adjust Claim Amount to Match Total Payment"></asp:Label><br/>
        for differences within +/-<asp:TextBox ID="txtMTP" runat="server" Enabled="False"></asp:TextBox>

1 个答案:

答案 0 :(得分:4)

将其更改为:

chk1.disabled = true;

它会起作用。要重新启用,只需将true更改为false。