使用Jqeury选择RadioButtonList时如何启用/禁用下拉列表 [英] How to Enable/Disable the Dropdownlists when selecting the RadioButtonList using Jqeury

查看:50
本文介绍了使用Jqeury选择RadioButtonList时如何启用/禁用下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有一个RadioButtonList和两个DropDownLists.

Hi guys, I have a RadioButtonList and Two DropDownLists.

<asp:RadioButtonList ID="rbnl" runat="server" RepeatDirection="Horizontal">
                               <asp:ListItem Text="Fresher" Value="0" Selected="True"></asp:ListItem>
                               <asp:ListItem Text="Experience" Value="1"></asp:ListItem>
                           </asp:RadioButtonList>



选择"Fresher"时(默认情况下处于选中状态)
禁用了两个DropDownLists.

选择体验"时

启用了两个DropDrownLists.


请任何人帮助我.



When Selecting the "Fresher" ( By default it is selected)
Disabled the two DropDownLists.

when selecting the "Experience"

Enabled the Two DropDrownLists.


please any one help me.

推荐答案

你好

使用以下javascript

Hello

Use following javascript

function checkRadioButton(id, id1) {
         var radio = document.getElementsByName(id);
         if (radio.length > 0) {
             for (var j = 0; j < radio[0].cells.length; j++) {
                 for (var k = 0; k < radio[0].cells[j].children.length; k++) {
                     if (radio[0].cells[j].children[k].checked == true && radio[0].cells[j].innerText == "Yes") {
                         document.getElementById(id1).disabled = false;
                     }
                     else if (radio[0].cells[j].children[k].checked == true && radio[0].cells[j].innerText == "No") {
                         document.getElementById(id1).disabled = true;
                     }
                 }
             }
         }
     }



然后在页面加载的.cs页面中使用以下代码


radiobuttonID.Attributes.Add("onClick","checkRadioButton(""+ RadioButtonID.ClientID +"''," + DropDownListID.ClientID +'')");

谢谢,
Abhimanyu Rawat



Then use following code in .cs page in page load


radiobuttonID.Attributes.Add("onClick", "checkRadioButton(''" + RadioButtonID.ClientID + "'',''" + DropDownListID.ClientID + "'')");

Thanks,
Abhimanyu Rawat


Its working check it :-)

<pre lang="Javascript">

<script type="text/javascript">


(function(){
(function () {


这篇关于使用Jqeury选择RadioButtonList时如何启用/禁用下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆