问题描述
大家好,我有一个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.
推荐答案
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">
这篇关于使用Jqeury选择RadioButtonList时如何启用/禁用下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!