I have a web form that contains two radiobuttonlist controls. I would like to hide certain radiobuttonlist list items in the 2nd radiobuttonlist whenever certain options are selected in the first radiobuttonlist.
I would like to hide the options using JavaScript.
I tried using the code below but the items were not hidden / removed.
<asp:RadioButtonList ID="rblEmpType" runat="server" onclick="hideRoleOption()" ClientIDMode="Static" RepeatDirection="Horizontal" >
<asp:ListItem Value="1">Employee</asp:ListItem>
<asp:ListItem Value="2">Manager</asp:ListItem>
</asp:RadioButtonList>
<asp:RadioButtonList ID="rblRole" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="1">Option 1</asp:ListItem>
<asp:ListItem Value="2">Option 2</asp:ListItem>
<asp:ListItem Value="3">Option 3</asp:ListItem>
<asp:ListItem Value="4">Option 4</asp:ListItem>
<asp:ListItem Value="5">Option 5</asp:ListItem>
</asp:RadioButtonList>
function hideRoleOption() {
var selEmpOption = document.getElementById('<%= rblEmpType.ClientID %>');
var selRoleOption = document.getElementById('<%= rblEmpRole.ClientID %>');
if (selEmpOption[1].checked) {
selRoleOption.getElementsByTagName('input')[0].nextSibling.style.display = 'none';
selRoleOption.getElementsByTagName('input')[0].style.display = 'none';
}
}