Reputation: 2615
In my web page, I have a table with a textbox. I want to hide the table row with the textbox If my ASP checkbox is checked. How can I do that?
This is what I have so far:
<table>
<tr>
<td>
<asp:CheckBox id="chkbxUS" runat="server" onchange="validate();" />
</td>
</tr>
<tr>
<td id="ParentCountryInfo">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
</table>
<script type="text/javascript">
function validate() {
if (document.getElementById('<%=chkbxUS.ClientID%>').checked) {
document.getElementById("ParentCountryInfo").style.visibility='visible';
} else {
document.getElementById("ParentCountryInfo").style.display='block';
}
}
</script>
Upvotes: 0
Views: 955
Reputation: 2107
Can you please try this:
<table>
<tr>
<td>
<asp:CheckBox ID="chkbxUS" runat="server" onchange="validate();" />
</td>
<td id="ParentCountryInfo">
<asp:TextBox ID="TextBox1" runat="server">Disappear me</asp:TextBox>
</td>
</tr>
</table>
<script type="text/javascript">
function validate() {
if (document.getElementById('<%=chkbxUS.ClientID%>').checked) {
document.getElementById("ParentCountryInfo").style.visibility = 'hidden';
} else {
document.getElementById("ParentCountryInfo").style.visibility = 'visible';
}
}
</script>
Upvotes: 1