I’m at my wit’s end when it comes to this. JavaScript definitely isn’t my strong suit and I’ve been trying to google for a solution. Here’s the code I have:
<asp:RadioButtonList ID="Group1Most" onClick="disable('Group1Most', 'Group1Least')" runat="server" >
<asp:ListItem Value="1"> |</asp:ListItem>
<asp:ListItem Value="2"> |</asp:ListItem>
<asp:ListItem Value="3"> |</asp:ListItem>
<asp:ListItem Value="4"> |</asp:ListItem>
</asp:RadioButtonList>
<asp:RadioButtonList ID="Group1Least" runat="server" >
<asp:ListItem Value="1"> This and That</asp:ListItem>
<asp:ListItem Value="2"> Fire and Ice</asp:ListItem>
<asp:ListItem Value="3"> Black and Tan</asp:ListItem>
<asp:ListItem Value="4"> Smith and Wesson</asp:ListItem>
</asp:RadioButtonList>
And here’s the JavaScript:
function disable(index, control)
{
var selected=($("[ID$=_"+index+"] input[type=radio]:checked").val());
//The rest of the stuff that I can't figure out
}
What I want to do is whenever you click a radio button on the Group1Most RadionButtonList, it will disable the corresponding radio button on the Group1Least RadioButtonList. The problem is I can’t figure out how to select an individual radio button within the RadioButtonList. Can anybody help me?
Try adding this jQuery to your page instead. You don’t need the disable function that you have written
Assuming the values match, this will work. You would also be able to do it by the index if you wanted to.
if you want to only have one item disabled at a time and re-enable a previously disabled item in the second group, include the following line as the first line in the click function. It will remove the disabled attribute from all inputs in the group
Edit:
In answer to comment from @Majid above, the output of the controls is like this: