c# - Send selectedText from AutocompleteTextView Automatically - Jquery / Asp.net -


i searched lot. created autocomplete jquery citytextbox , selecteditem autocomplete textbox. split selecteditem "|" , assign string[] lines after user select autocomplete view. on code assign lines below( lines[0] citytextbox , lines[1] postcodetextbox);

 $('#postcodetextbox').text = $("#<%=postcodetextbox.clientid%>").val(lines[1].trim());                              $('#citytextbox').text = $("#<%=citytextbox.clientid%>").val(lines[0].trim());                          });

this works fine after select when click somewhere or focus ect(events define in $("#citytextbox").bind()). happens. want send lines[0] , lines[1] text boxes automatically when select autocomplete list without click etc. can see java script code below:

$(function () {          $("#citytextbox").autocomplete({              source: function (request, response) {                  var param = { cityname: $('#citytextbox').val() };                  $.ajax({                      url: "default.aspx/getcities",                      data: json.stringify(param),                      datatype: "json",                      type: "post",                      contenttype: "application/json; charset=utf-8",                      datafilter: function (data) { return data; },                      success: function (data) {                          response($.map(data.d, function (item) {                              return {                                  value: item                              }                          }))                      },                      //error: function (xmlhttprequest, textstatus, errorthrown) {                      //    alert(textstatus);                      //}                  });              },              select: function (event, ui) {                  if (ui.item) {                      var parameter = { selecteditem: ui.item.value }                      function process() {                          entered = $('#citytextbox').val();                          lines = entered.split("|");                          $(function getlines () {                              $('#postcodetextbox').text = $("#<%=postcodetextbox.clientid%>").val(lines[1].trim());                              $('#citytextbox').text = $("#<%=citytextbox.clientid%>").val(lines[0].trim());                          });                      }                                     }                  $(document).ready(function () {                      //$("#citytextbox").bind('mouseout', process);                      $("#citytextbox").bind('blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup errorscroll errorkeydown   ', process);                                        });              },              minlength: 3          });      });

i data esd table in database. , query work properly. here html code part :

<table style="margin:50px; padding:10px">              <tr>                  <td colspan="2">                      <asp:label id="countrylabel" runat="server" text="Ülke : "></asp:label>                  </td>                  <td colspan="2">                      <div>                          <asp:dropdownlist id="countrydropdownlist" runat="server" autopostback="true" onselectedindexchanged="countrydropdownlist_selectedindexchanged" tabindex="-1">                          </asp:dropdownlist>                      </div>                  </td>              </tr>              <tr>                  <td colspan="3" >                                   <asp:label id="postcodelabel" runat="server" text="posta kodu :"></asp:label></td>                  <td colspan="3">                      <asp:textbox id="postcodetextbox" runat="server"></asp:textbox>                  </td>                              </tr>              <tr>                  <td colspan="3">                      <asp:label id="citylabel" runat="server" text="Şehir : "></asp:label>                  </td>                  <td colspan="3">                      <asp:textbox id="citytextbox" runat="server"></asp:textbox>                                      </td>              </tr>          </table>


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -