RadioButtonList和CheckBoxList的JS操作

 

<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal"   οnclick="javascript:radioListSelectedChanged();">

      <asp:ListItem Value="1" >是</asp:ListItem>

      <asp:ListItem Value="0" >否</asp:ListItem>

 </asp:RadioButtonList>

<asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" >

</asp:CheckBoxList>

 $(document).ready(function()

        {

           var radioBtnList1=document.all("RadioButtonList1");

           var txt=document.all("txt1");

           var checklist=document.all("CheckBoxList_uploadFileType");

         var item0=radioBtnList1.cells[0].getElementsByTagName("input")[0];//注意对象的取法,可跟踪察看

           if((item0!=null)&&(item0.checked==true))//选择“是”

           {

             txt.disabled=false;

            var checklist=document.getElementById("<%=CheckBoxList1.ClientID%>");

           if(checklist==null) return;

          for(var i=0;i<document.getElementById("CheckBoxList1").getElementsByTagName("input").length;i++)

 

            {

              var temp=document.getElementById("CheckBoxList1").getElementsByTagName("input")[i];

              temp.disabled=false;

 

            }          

           }

           else

           {

           txt.disabled=true;

           txt.value="";

            var checklist=document.all("CheckBoxList1");

           if(checklist==null) return;

             for(var i=0;i<document.getElementById("CheckBoxList1").getElementsByTagName("input").length;i++)

 

            {

 

               var temp=document.getElementById("CheckBoxList1").getElementsByTagName("input")[i];

               temp.disabled=true;

               temp.checked=false;

            }          

           }

           //页面是否提交成功

               var opResultType=document.getElementById("<%=HiddenField_opResultType.ClientID%>");//服务器端提交控件的事件中赋值

               switch(opResultType.value)

               {

                  case "as":

                    alert('成功添加!');

                    break;

                    case "us":

                    alert('成功更新!');

                    break;

                  case "af":

                    alert('失败!');

                    break;

                    case "uf":

                    alert('失败!');

                    break;

                  default:

                    break;

               }

        }

        )

 

        function radioListSelectedChanged()

        {

        //debugger;

         var radioBtnList1=document.all("RadioButtonList1");

          var txt=document.all("txt1");

 

         if(radioBtnList1!=null)

        {

          var item0=radioBtnList1.cells[0].getElementsByTagName("input")[0];//注意对象的取法,可跟踪察看

           if((item0!=null)&&(item0.checked==true))//选择“是”

          if(item0.checked)//是

          {

             txt.disabled=false;

            var checklist=document.getElementById("<%=CheckBoxList1.ClientID%>");

           if(checklist==null) return;

          for(var i=0;i<document.getElementById("CheckBoxList1").getElementsByTagName("input").length;i++)

 

            {

              var temp=document.getElementById("CheckBoxList1").getElementsByTagName("input")[i];

              temp.disabled=false;

 

            }          

 

          }

          else

          {

            txt.disabled=true;

            txt.value="";

            var checklist=document.all("CheckBoxList1");

           if(checklist==null) return;

             for(var i=0;i<document.getElementById("CheckBoxList1").getElementsByTagName("input").length;i++)

 

            {

 

               var temp=document.getElementById("CheckBoxList1").getElementsByTagName("input")[i];

               temp.disabled=true;

               temp.checked=false;

            }          

          }

        }

        }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值