0
我有一个Web应用程序,其中我使用页面加载时使用来自数据库的项目填充multiselectlistbox。在jquery中使用.keypress事件检测输入按钮
我从列表框中获取所有选中的项目,但它们都是按顺序填充的。
我希望这些项目按它们被用户选择的顺序排列。
因此对于这个问题,我发现解决方案使用客户端.click()
事件在列表框中,因为我检测选定的项目,并保持它的值在hiddenfield.This运作良好,但问题出现时,用户按下输入键点击鼠标点击选择项目。这时它不火。点击()事件,所以我已经使用 onkeypress()
,onkeyup()
但它在所有
这里犯规火是我的代码:
<script type="text/javascript">
$(document).ready(function() {
$(".chzn-results .active-result").click(function(event) {
var hdfld = document.getElementById("hdn_menuitems");
if (hdfld.value == "") {
hdfld.value = $(this).index();
}
else {
hdfld.value = hdfld.value + "," + $(this).index();
}
});
$(".chzn-results .active-result").keydown(function(event) {
$(".chzn-results .active-result").keyup(function(event) {
alert("Event");
if(event.keyCode==13)
{
var hdfld = document.getElementById("hdn_menuitems");
if (hdfld.value == "") {
hdfld.value = $(this).index();
}
else {
hdfld.value = hdfld.value + "," + $(this).index();
}
}
});
});
</script>
这是我的列表框:
<asp:ListBox ID="dr_menuitem" runat="server" class="chzn-select" style="width:575px;" SelectionMode="Multiple" >
<asp:ListItem></asp:ListItem>
</asp:Listbox>
我一直在使用使用列表框[http://harvesthq.github.com/chosen/][1]
Siva Charan,它不起作用 这个事件不会在按下输入事件时被解雇。 – sharad 2012-07-14 05:49:49