ASP.NET 彈窗顯示/隱藏文本框

新增彈窗:這裏需要根據所選的“供方類別”來判斷是否隱藏“工號”的文本框。

 <div align="center" style=" display:none; " id="divnew">
    <table style="border: 1px solid #7DBEFF">
        
       
         <tr>
            <td align="right" >供方類別:</td>
            <td align="left">
                <asp:DropDownList ID="ddl_supplierType" runat="server"  OnChange ="sup()" >
                    <asp:ListItem Value="" Text="" />
                    <asp:ListItem Value="Z001" Text="供方" />
                    <asp:ListItem Value="Z002" Text="關聯方" />
                    <asp:ListItem Value="Z003" Text="個人" />
                </asp:DropDownList> 
                <a style="color: #FF0000">*</a>
            </td>
        </tr>
       
         <tr>
            <td align="right" id="txt_gh">工號:</td>
            <td align="left" id="txt_ghtd">
                <input type="text" id="Txt_newgfbh"  style="width:200px"/>
                <a style="color: #FF0000">*</a>
            </td>
        </tr>
        
       
        <tr><td>.</td></tr>
        <tr>
            
            <td colspan="2" align="center">
                <input type="button" id="Btn_newsave" value="保存" />&nbsp;&nbsp;&nbsp;
                <input type="button" id="Btn_newcancel" value="取消" οnclick="closes()" />
            </td>
        </tr>
    </table>
  </div>

JavaScript部分:

 <script type="text/javascript">
        
        function sup()
        {
     
            if ($("#<%=ddl_supplierType.ClientID %>").val() == "Z001")
            {
                document.getElementById("txt_gh").style.display = "none";
                document.getElementById("txt_ghtd").style.display = "none";
            }
               if ($("#<%=ddl_supplierType.ClientID %>").val() == "Z002")
            {
                document.getElementById("txt_gh").style.display = "none";
                document.getElementById("txt_ghtd").style.display = "none";
               }
               if ($("#<%=ddl_supplierType.ClientID %>").val() == "Z003")
            {
                document.getElementById("txt_gh").style.display = "";
                document.getElementById("txt_ghtd").style.display = "";
            }
        }


    </script>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章