Good morning. I have the following code:
HTML:
<asp:CheckBox ID="ckPergunta" runat="server" onchange='SelectChoices(this);' />
JavaScript:
<script type="text/javascript">
SelectChoices();
function SelectChoices() {
var opc = document.getElementById('<%=ckPergunta.ClientID%>').checked;
if (opc == false) {
document.getElementById('<%=dlTipoResposta.ClientID %>').style.display = "none";
document.getElementById('<%=txtRes.ClientID %>').style.display = "none";
}
else {
document.getElementById('<%=dlTipoResposta.ClientID %>').style.display = "block";
document.getElementById('<%=txtRes.ClientID %>').style.display = "block";
}
}
</script>
It happens that when I check, in checkBox the JavaScript code does not run. In other words, nothing happens. But if I put an onChange in an asp: TextBox the JavaScrip code works fine. What's wrong?