【问题标题】:Multi Autocomplete in same page同一页面中的多个自动完成
【发布时间】:2012-07-11 15:46:29
【问题描述】:

我想创建多个自动完成,但我只能创建一个。 它必须与不同的查询一起工作。 我的代码是这样的。

  $(document).ready(function(){
   $("#arama").keyup(function(){
    data_getir($(this).val());
   });
  });
  function data_getir(aranan)
  {
    $.ajax({
      type: "POST",
      url: "web.asmx/oku?aranan=" + aranan, //web service ve methodumuz
      data: "{adres:'complete.ascx'}",
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: function(msg){
        $("#goster").html(msg.d)
      }
    });
  }
  function sec(kontrol){$("#arama").val($(kontrol).html()); $("#goster").html("");}




<div>
  <input id="arama" type="text" style="width:150px; height:20px; font-size:11pt;" />
  <div id="goster"></div>
</div>

还有js:jquery-1.2.6.pack.js

如何将它与同一页面中的另一个查询一起使用?

【问题讨论】:

    标签: c# jquery asp.net autocomplete


    【解决方案1】:

    只需生成一个新函数并将其绑定到您要用作自动完成字段的其他输入,一页中可以有多少个自动完成是没有限制的。

    $(document).ready(function(){
       $("#arama").keyup(function(){
        data_getir($(this).val());
       });
    
       $("#autocomplete_bis").keyup(function(){
        data_getautocomplete_bis($(this).val());
       });
      });
      function data_getir(aranan)
      {
    
      }
    
     function data_getautocomplete_bis(aranan){
     $.ajax({
          type: "POST",
          url: "web.asmx/oku?new_query=" + aranan, //web service ve methodumuz
          data: "{adres:'complete.ascx'}",
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function(msg){
            $("#autocomplete_bis_goster").html(msg.d)
          }
        });
    }
      function sec(kontrol){
    $("#arama").val($(kontrol).html()); 
    $("#goster").html("");
    }
    
    
    <div>
      <input id="arama" type="text" style="width:150px; height:20px; font-size:11pt;" />
      <div id="goster"></div>
      <input id="autocomplete_bis" type="text" style="width:150px; height:20px; font-size:11pt;" />
      <div id="autocomplete_bis_goster"></div>
    </div>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-05
      • 2012-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-18
      相关资源
      最近更新 更多