How do you set a default value with jquery auto complete combobox?

后端 未结 14 1922
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-28 19:01

When using the jquery ui autocomplete combobox, can you set a default value for the combobox?

相关标签:
14条回答
  • 2020-12-28 19:31
    function setAutoCompleteCombo(id,value,display) {
        if($(id+"[value="+value+"]").text().localeCompare("")==0){
            $("<option value='"+value+"'>"+display+"</option>").appendTo($(id));
        }
        $(id).val(value);
        $(id).next().val($(id+" :selected").text());
    }
    

    I solved it by calling this function on the initial page or runtime. Example:

    setAutoCompleteCombo('#frmData select#select_id',option_value,option_text);
    
    0 讨论(0)
  • 2020-12-28 19:32

    add method to jquery combobox script

    setValue: function(o) {            
        $(this.element).val(o);
        $(this.input).val($(this.element).find("option:selected").text());            
    }
    
    0 讨论(0)
提交回复
热议问题