JQuery autocomplete how to write label in autocomplete text input?

前端 未结 5 1927
花落未央
花落未央 2020-12-18 05:57

Hello I am using jQuery UI autocomplete.

I am getting values and labels from the drop down area. I will write the value in a hidden input and use it later. I could d

5条回答
  •  星月不相逢
    2020-12-18 06:35

    Solution: Add a return false; after setting the labels.

    var selectedLabel = null;
          var yerler = [
         { "value": 3, "label": "Adana Seyhan" }, 
         { "value": 78, "label": "Seyhan Adana" },
         { "value": 17, "label": "Paris Fransa" }, 
         { "value": 123, "label": "Tokyo Japan"}];
    
          $("#tags").autocomplete({
              source: yerler,
              select: function (event, ui) {
    
                  $("#projeKatmanRaporCbx").val(ui.item.value);
                  $("#tags").val(ui.item.label);
    
                  return false;
              }
          });
    

提交回复
热议问题