在javascript onchange中隐藏图像

时间:2014-04-07 02:01:29

标签: c# javascript asp.net

我想在这里使用javascript隐藏图片我的代码。不幸的是它没有用。

 function showLoader(loaderType) {
        if (loaderType == "AO") {
            document.getElementById("VAO").style.display = '';
        }
        else if (loaderType == "NatureOfBusiness") {
            document.getElementById("ctl00_details_check").style.display = 'none';
            document.getElementById("validateBusiness").style.display = '';
        }
        else if (loaderType == "Button") {
            document.getElementById("loaderButton").style.display = '';
        }
    }

aspx代码

   <asp:TextBox onchange="showLoader('NatureOfBusiness')" ID="txtNatureOfBusiness" Width="200"
   runat="server" CssClass="txt-box" OnTextChanged="txtNatureOfBusiness_TextChanged"
   AutoPostBack="true"></asp:TextBox>

    <img id='check' runat="server" visible="false" src='../images/check.png' style='height: 20px;' />
    <img id='cross' runat="server" visible="false" src='../images/cross.png' style='height: 17px;' />
    <img id='validateBusiness' src='../images/updating.gif' style="display: none; height: 12px;" />

1 个答案:

答案 0 :(得分:0)

您应该将javascript:添加到onchange方法,如下所示。

   <asp:TextBox onchange="javascript:showLoader('NatureOfBusiness')" ID="txtNatureOfBusiness" Width="200"
   runat="server" CssClass="txt-box" OnTextChanged="txtNatureOfBusiness_TextChanged"
   AutoPostBack="true"></asp:TextBox>