[英]Hide Table Row with ASP Control Checkbox
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.
如果我的ASP复选框被选中,我想用文本框隐藏表格行。 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>
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.