如何将下拉列表中的选定值发送到标签?
问题描述:
For some reason i just cant get it to work:
<asp:DropDownList ID="DDSortBy" runat="server" CssClass="RightDD" OnSelectedIndexChanged="DDSortBy_SelectedIndexChanged">
<asp:ListItem Value="0">Random</asp:ListItem>
<asp:ListItem Value="1">Album</asp:ListItem>
<asp:ListItem Value="2">Artist</asp:ListItem>
<asp:ListItem Value="3">Price</asp:ListItem>
<asp:ListItem Value="4">Top Rated</asp:ListItem>
<asp:ListItem Value="5">Year</asp:ListItem>
</asp:DropDownList>
i want to send the values "Random", "Album", etc to this label:
<asp:Label ID="lblSort" runat="server" Text=""></asp:Label>
Any Ideas?
答
使用Jquery从下拉列表中获取所选值并将其分配给标签文本..
var selectedvaluefromddl =
Hi,
Use Jquery to get the selected value from dropdown and assign that to label text..
var selectedvaluefromddl =
(#DDSortBy option:selected)。text();
("#DDSortBy option:selected").text();
('#lblSort' ).text(selectedvaluefromddl);
('#lblSort').text(selectedvaluefromddl );