在我的网页中,我有一个带有文本框的表格。我想用文本框隐藏表行如果选中我的ASP复选框。我怎么能这样做?
这是我到目前为止所做的:
<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>
答案 0 :(得分:1)
请你试试这个:
<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>