Jquery autocomplete on select event

前端 未结 2 451
粉色の甜心
粉色の甜心 2020-12-15 06:47

I am using jQuery autocomplete and its working fine, now I want to store a variable in session from jQuery when following condition occurs.

When someone types any w

2条回答
  •  余生分开走
    2020-12-15 07:40

    So if I understand correctly you want to store the selected value in a variable sessions

    you can get the value out of the selected item through following code:

      $(".autosearch-smart").autocomplete('Home/GetCompanyNames', {
    minChars: 1,
    width: 402,
    matchContains: "word",
    autoFill: true,
    select: function (event, ui) {
        var label = ui.item.label;
        var value = ui.item.value;
       //store in session
      document.valueSelectedForAutocomplete = value 
    }
    });
    

    the value and label are json objects that came from the server

    Hope this helps

提交回复
热议问题