ASP面板應通過ASP複選框使用JavaScript函數製作ASP面板通過ASP複選框可見的JavaScript
我公司要我改變某個特定頁面上的編碼來使人們看到,在要求是當你點擊一個複選框時,一個面板應該變得可見,但它不應該被回發。 所以他們要求我使用JavaScript並實現這個要求。
我試過這段代碼,當我看到它時,JavaScript函數找不到id,因爲面板將被動態創建。所以任何人都可以幫助我做到這一點?
重要提示:它應該停止發回!!!
我的代碼是:
<script type="text/javascript">
function fun1()
{
if (document.getElementById("CheckBox1").checked == true)
{
document.getElementById("Panel3").visible = true;
}
}
</script>
<form id="form1" runat="server">
<asp:Panel ID="Panel1" runat="server" Height="89px">
<asp:CheckBox ID="CheckBox1" runat="server" OnClick="fun1()" />
</asp:Panel>
<br />
<asp:Panel ID="Panel3" runat="server" Height="91px" Visible="False">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button2" runat="server" Text="Button" />
</asp:Panel>
<br />
</form>
對不起document.getElementById(「Panel3」)。visible = true; –