【发布时间】:2012-07-01 02:31:45
【问题描述】:
我有一个 Web 应用程序,我在其中使用页面加载时数据库中的项目填充列表框。
我从列表框中获取所有被选中的项目,但它们是按照它们填充的顺序排列的。
我希望这些项目按照用户选择的顺序排列。
我尝试使用 jQuery .change(function(),但它只返回第一个选定项的值。
我附上我的代码以供参考。我使用http://harvesthq.github.com/chosen/使用列表框
这是我的列表框:
<asp:ListBox ID="dr_menuitem" runat="server" class="chzn-select" SelectionMode="Multiple" style="width:300px;" >
<asp:ListItem></asp:ListItem>
</asp:Listbox>
这是我调用的 jQuery:
<script type="text/javascript">
$(document).ready(function() {
$('#dr_menuitem').change(function() {
alert($("#dr_menuitem option:selected").val());
});
});
</script>
【问题讨论】:
-
您需要跟踪更改,请参阅此问题以获得一些想法:stackoverflow.com/questions/3308460/…
-
我需要同样的东西..我想知道我找到的最后一个选择@http://stackoverflow.com/questions/3308460/getting-the-newest-selected-options-text-from-multiple-select-list..信用归标记..
标签: jquery asp.net listbox multi-select