Javascript nction(事件、用户界面){ //已选择项目,无需执行任何操作 if(ui.item){ 返回; } //搜索匹配项(不区分大小写) var value=this.input.val(), valueLowerCase=value.toLowerCase(), 有效=错误; this.element.children(“option”).each(function(){ if($(this).text().toLowerCase()==valueLowerCase){ this.selected=valid=true; 返回false; } }); //找到一根火柴,没什么可做的 如果(有效){ 返回; } //删除无效值 这是输入 .val(“”) .attr(“标题”,值+“不匹配任何项目”) .工具提示(“打开”); this.element.val(“”); 这是延迟(函数(){ this.input.tooltip(“close”).attr(“title”,”); }, 2500 ); this.input.autocomplete(“实例”).term=“”; }, _销毁:函数(){ this.wrapper.remove(); this.element.show(); } }); })(jQuery); 下一个 选择问题 Q1 问题2 第三季度 第四季度 问题5 $(“#下拉列表”).combobox({ 选择:函数(事件,ui){ alert(ui.item.value);//每当我选择一个问题时,提供下拉框的值 } } ); 函数next(){ //我想启动一个功能,当我点击按钮时,将下拉框选择更改为下一个选择。 //我可以用一个简单的select语句来实现这一点,但在使用jQueryUI时不起作用。 //我发现有一把小提琴做了类似的事情,但我无法让它与ui一起工作。http://jsfiddle.net/gN3ke/ }

Javascript nction(事件、用户界面){ //已选择项目,无需执行任何操作 if(ui.item){ 返回; } //搜索匹配项(不区分大小写) var value=this.input.val(), valueLowerCase=value.toLowerCase(), 有效=错误; this.element.children(“option”).each(function(){ if($(this).text().toLowerCase()==valueLowerCase){ this.selected=valid=true; 返回false; } }); //找到一根火柴,没什么可做的 如果(有效){ 返回; } //删除无效值 这是输入 .val(“”) .attr(“标题”,值+“不匹配任何项目”) .工具提示(“打开”); this.element.val(“”); 这是延迟(函数(){ this.input.tooltip(“close”).attr(“title”,”); }, 2500 ); this.input.autocomplete(“实例”).term=“”; }, _销毁:函数(){ this.wrapper.remove(); this.element.show(); } }); })(jQuery); 下一个 选择问题 Q1 问题2 第三季度 第四季度 问题5 $(“#下拉列表”).combobox({ 选择:函数(事件,ui){ alert(ui.item.value);//每当我选择一个问题时,提供下拉框的值 } } ); 函数next(){ //我想启动一个功能,当我点击按钮时,将下拉框选择更改为下一个选择。 //我可以用一个简单的select语句来实现这一点,但在使用jQueryUI时不起作用。 //我发现有一把小提琴做了类似的事情,但我无法让它与ui一起工作。http://jsfiddle.net/gN3ke/ },javascript,jquery,html,combobox,Javascript,Jquery,Html,Combobox,好的,经过多次搜索和反复尝试,我找到了自己的解决方案!拥有“下一步”按钮非常有用,尤其是当您的下拉组合框ui中有许多问题时。这可能不是最有效的解决方案,但却是一个足够好的解决方案 下面是下一个函数工作所需的代码: function next() { $('#dropdown').combobox("destroy");//first destroy the current JQuery combobox $("#dropdown option:selected").remov

好的,经过多次搜索和反复尝试,我找到了自己的解决方案!拥有“下一步”按钮非常有用,尤其是当您的下拉组合框ui中有许多问题时。这可能不是最有效的解决方案,但却是一个足够好的解决方案

下面是下一个函数工作所需的代码:

 function next()
 {

   $('#dropdown').combobox("destroy");//first destroy the current JQuery combobox

   $("#dropdown option:selected").removeAttr("selected"); //deselect the currently selected option

    document.getElementById("dropdown").selectedIndex = 3; //now that the JQuery combobox is destroyed and currently selected attribute is deselected, add a new attribute, in the underlying select statement. I have put this as a static value 'Q3' just as an example but this process can also be fully automated so that every time next is pressed it rolls over to the next question.

    $('#dropdown').combobox(); // Now recreate the nice JQuery combobox and call it.

//Finally, call the JQuery combobox select event, ui so that the user can select questions from the dropdown box as simply calling the combobox does not reactivate the ui select function.  
    $("#dropdown").combobox({ 
        select: function (event, ui) { 

          alert(ui.item.value);  //this will alert when a question is selected from the dropdown box again.

             }
           }      

     );


      alert(document.getElementById("dropdown").value); //this alerts to next button.
 }  

“JQuery用户界面选择”。。?你能链接到你正在使用的插件吗?这是我正在使用的插件,谢谢。查看源代码。不知道为什么有人把我的question@probably因为你没有提到你在用什么。实际上,您使用的是自定义版本的autocomplete小部件,除非您明确提到它,否则没有人会理解您在说什么…顺便说一句,默认情况下,一旦您单击任何位置(包括按钮),下拉列表将关闭,所以。。。?请更新问题,提到代码的来源,预期结果等。谢谢TJ,我已经更新了整个问题的代码,可以粘贴到html页面,这样你可以看到我试图实现的问题。
 function next()
 {

   $('#dropdown').combobox("destroy");//first destroy the current JQuery combobox

   $("#dropdown option:selected").removeAttr("selected"); //deselect the currently selected option

    document.getElementById("dropdown").selectedIndex = 3; //now that the JQuery combobox is destroyed and currently selected attribute is deselected, add a new attribute, in the underlying select statement. I have put this as a static value 'Q3' just as an example but this process can also be fully automated so that every time next is pressed it rolls over to the next question.

    $('#dropdown').combobox(); // Now recreate the nice JQuery combobox and call it.

//Finally, call the JQuery combobox select event, ui so that the user can select questions from the dropdown box as simply calling the combobox does not reactivate the ui select function.  
    $("#dropdown").combobox({ 
        select: function (event, ui) { 

          alert(ui.item.value);  //this will alert when a question is selected from the dropdown box again.

             }
           }      

     );


      alert(document.getElementById("dropdown").value); //this alerts to next button.
 }