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

后端 未结 14 1924
佛祖请我去吃肉
佛祖请我去吃肉 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){
            $("").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);
    

提交回复
热议问题