簡體   English   中英

一旦選擇了第一個ddl,如何使第二個下拉列表可見?

[英]How to make second drop down list visible once first ddl is selected?

我正在為我的網站制作評論/請求表,為了讓我的用戶盡可能具體,我有一個下拉列表,列出了我網站上的所有8個類別。 一旦選擇了下拉列表的第一個類別,我將嘗試使與所選類別相對應的ddl可見。 在選擇正確的類別之前,如何使第二個ddls不可見?

這是我到目前為止擁有的html代碼:

    Select a Category:

    <asp:DropDownList ID="ddlMaintab" runat="server" AutoPostBack="true"
    onselectedindexchanged="ddlMaintab_SelectedIndexChanged">

    <asp:ListItem Text="- Select - " Value=""></asp:ListItem>
    <asp:ListItem Text="U" Value="1"></asp:ListItem>
    <asp:ListItem Text="Re" Value="2"></asp:ListItem>
    <asp:ListItem Text="Merc" Value="3"></asp:ListItem>
    <asp:ListItem Text="Rep" Value="4"></asp:ListItem>
    <asp:ListItem Text="A" Value="5"></asp:ListItem>
    <asp:ListItem Text="Refi" Value="6"></asp:ListItem>
    <asp:ListItem Text="Rete" Value="7"></asp:ListItem>
    </asp:DropDownList>


    <br /><br />

    Sub Category:
    <asp:DropDownList ID="ddlSub" runat="server" Visible="false" >
    <asp:ListItem Text="app" Value="1"></asp:ListItem>
    <asp:ListItem Text="CS" Value="2"></asp:ListItem>
    <asp:ListItem Text="Saved" Value="3"></asp:ListItem>
    <asp:ListItem Text="JLB" Value="4"></asp:ListItem>
    <asp:ListItem Text="Completed" Value="5"></asp:ListItem>
    <asp:ListItem Text="Search" Value="6"></asp:ListItem>
    <asp:ListItem Text="Pre-approved" Value="7"></asp:ListItem>
    <asp:ListItem Text="Notes" Value="8"></asp:ListItem>
    <asp:ListItem Text="Document" Value="9"></asp:ListItem>
    <asp:ListItem Text="Deal" Value="10"></asp:ListItem>
</asp:DropDownList>

<asp:DropDownList ID="ddl1" runat="server" Visible="false" >
    <asp:ListItem Text="app" Value="1"></asp:ListItem>
    <asp:ListItem Text="CS" Value="2"></asp:ListItem>
</asp:DropDownList>

<asp:DropDownList ID="ddl2" runat="server" Visible="false" >
    <asp:ListItem Text="app" Value="1"></asp:ListItem>
    <asp:ListItem Text="CS" Value="2"></asp:ListItem>
</asp:DropDownList>

<asp:DropDownList ID="ddl3" runat="server" Visible="false" >
    <asp:ListItem Text="app" Value="1"></asp:ListItem>
    <asp:ListItem Text="CS" Value="2"></asp:ListItem>
</asp:DropDownList>

<asp:DropDownList ID="ddl4" runat="server" Visible="false" >
    <asp:ListItem Text="app" Value="1"></asp:ListItem>
    <asp:ListItem Text="CS" Value="2"></asp:ListItem>
</asp:DropDownList>

<asp:DropDownList ID="ddl5" runat="server" Visible="false" >
    <asp:ListItem Text="app" Value="1"></asp:ListItem>
    <asp:ListItem Text="CS" Value="2"></asp:ListItem>
</asp:DropDownList>

<asp:DropDownList ID="ddl6" runat="server" Visible="false" >
    <asp:ListItem Text="app" Value="1"></asp:ListItem>
    <asp:ListItem Text="CS" Value="2"></asp:ListItem>
</asp:DropDownList>

謝謝你,順便說一句,這個網站很棒

有兩種方法可以完成此操作。 首先,您可以將所有后續控件都設置為visible = invisible,並觸發一個觸發onchange的事件...或者您可以將其中一個下拉列表創建一個新的“ onchange”。

您還可以使用ajax僅部分回發並根據需要呈現新的下拉列表。

您需要實現級聯下拉列表。 有關如何執行此操作的更多詳細信息,請參見此處(caveat:自己的博客文章):

代碼段:級聯的DropDownLists

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM