Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys, I have a RadioButtonList and Two DropDownLists.

XML
<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>


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.
Posted
Updated 4-Nov-12 22:50pm
v2
Comments
Sanjeev Alamuri 5-Nov-12 4:57am    
http://www.codeproject.com/Answers/487906/HowplustoplusEnableplustheplusDropdownListplususin#answer1
CH Guravaiah 5-Nov-12 5:04am    
doesn't working code.
Ankur\m/ 5-Nov-12 5:27am    
Because the code isn't complete. You need to edit it to suit your requirement.

Hello

Use following javascript

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;
                     }
                 }
             }
         }
     }


Then use following code in .cs page in page load


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

Thanks,
Abhimanyu Rawat
 
Share this answer
 
Comments
CH Guravaiah 5-Nov-12 5:24am    
thanks, but we are using Jquery.
XML
Its working check it :-)

<pre lang="Javascript">

<script type="text/javascript">
         $(function () {
             $('#<%=ddlMin.ClientID %>').attr("disabled", true);
             $('#<%=ddlMax.ClientID %>').attr("disabled", true);
             $('#<%=rbnl.ClientID %>').click(function (e) {
                 if ($(this).find("input:checked").val() == "0") {
                     $('#<%=ddlMin.ClientID %>').attr("disabled", true);
                     $('#<%=ddlMax.ClientID %>').attr("disabled", true);
                  }
                 else if ($(this).find("input:checked").val() == "1") {
                     $('#<%=ddlMin.ClientID %>').attr("disabled", false);
                     $('#<%=ddlMax.ClientID %>').attr("disabled", false);
                 }

             });
         });


    </script></pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900