我正在尝试根据另一个单选按钮选择的答案禁用或启用单选按钮列表,这是我放在一起但未能成功使其工作的代码:
<script type="text/javascript">
// enable May we contact your present employer if Employed Now is yes
function EmployedNowYes(answer) {
if (answer == "Yes") {
document.getElementById("<%=ContactEmployer.ClientID %>").enabled = true;
}
if (answer == "No") {
document.getElementById("<%=ContactEmployer.ClientID %>").enabled = false;
}
}
</script>
Are you employed now?
<asp:RadioButtonList ID="EmployedNow" runat="server" RepeatDirection="Horizontal" >
<asp:ListItem Value="Yes" onclick ="EmployedNowYes(this.value)">Yes</asp:ListItem>
<asp:ListItem Value="No" onclick ="EmployedNowYes(this.value)">No</asp:ListItem>
</asp:RadioButtonList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ControlToValidate="EmployedNow"
ErrorMessage="* Required field." ForeColor="Red"> </asp:RequiredFieldValidator>
</td><td class="style42" valign="top">
May we contact your present employer:
<asp:RadioButtonList ID="ContactEmployer" runat="server" RepeatDirection="Horizontal">
<asp:ListItem >Yes</asp:ListItem>
<asp:ListItem >No</asp:ListItem>
</asp:RadioButtonList>
</td>