Click here to Skip to main content
15,748,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii,
I have two radiobutton list,
i have manuaaly entered two values for each radiobutton list .

Now i want to chnage index of second radiobutton list if i change index of first radio button list .. How can i do that .. in page source it shows id as contentplaceholder1_rdofirst_0 / _1

same for second .. How can i do that using jquery
Posted

1 solution

Try like this..


HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script src="jquery-1.10.2.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {

            $('#RadioButtonList1 input').change(function () {

                var index = $('#RadioButtonList1 input').index(this);

                $('#RadioButtonList2 input').each(function (_index, item) {

                    if (_index == index) {
                        $(item).prop('checked', true);
                    }

                });
            });

        });

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:RadioButtonList runat="server" ID="RadioButtonList1">
        <asp:ListItem Text="one" />
        <asp:ListItem Text="two" />
        <asp:ListItem Text="three" />
    </asp:RadioButtonList>
    <asp:RadioButtonList runat="server" ID="RadioButtonList2">
        <asp:ListItem Text="one" />
        <asp:ListItem Text="two" />
        <asp:ListItem Text="three" />
    </asp:RadioButtonList>
    </form>
</body>
</html>
 
Share this answer
 
Comments
Torakami 16-Jan-14 1:31am    
But where to call this function from ..
Karthik_Mahalingam 16-Jan-14 1:50am    
no need to call the function. it will bind the event by its own..
Torakami 16-Jan-14 1:41am    
And the code is not working ..
Karthik_Mahalingam 16-Jan-14 1:50am    
add jquery reference to it

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