• <small id='ZKXER'></small><noframes id='ZKXER'>

          <bdo id='ZKXER'></bdo><ul id='ZKXER'></ul>
      1. <legend id='ZKXER'><style id='ZKXER'><dir id='ZKXER'><q id='ZKXER'></q></dir></style></legend>

        <i id='ZKXER'><tr id='ZKXER'><dt id='ZKXER'><q id='ZKXER'><span id='ZKXER'><b id='ZKXER'><form id='ZKXER'><ins id='ZKXER'></ins><ul id='ZKXER'></ul><sub id='ZKXER'></sub></form><legend id='ZKXER'></legend><bdo id='ZKXER'><pre id='ZKXER'><center id='ZKXER'></center></pre></bdo></b><th id='ZKXER'></th></span></q></dt></tr></i><div id='ZKXER'><tfoot id='ZKXER'></tfoot><dl id='ZKXER'><fieldset id='ZKXER'></fieldset></dl></div>
      2. <tfoot id='ZKXER'></tfoot>

        使用带有多个输入字段的 jquery-ui 自动完成功能

        using jquery-ui autocomplete with multiple input fields(使用带有多个输入字段的 jquery-ui 自动完成功能)
          <tbody id='6dus2'></tbody>

          <tfoot id='6dus2'></tfoot>

              <small id='6dus2'></small><noframes id='6dus2'>

            • <i id='6dus2'><tr id='6dus2'><dt id='6dus2'><q id='6dus2'><span id='6dus2'><b id='6dus2'><form id='6dus2'><ins id='6dus2'></ins><ul id='6dus2'></ul><sub id='6dus2'></sub></form><legend id='6dus2'></legend><bdo id='6dus2'><pre id='6dus2'><center id='6dus2'></center></pre></bdo></b><th id='6dus2'></th></span></q></dt></tr></i><div id='6dus2'><tfoot id='6dus2'></tfoot><dl id='6dus2'><fieldset id='6dus2'></fieldset></dl></div>
              1. <legend id='6dus2'><style id='6dus2'><dir id='6dus2'><q id='6dus2'></q></dir></style></legend>
                  <bdo id='6dus2'></bdo><ul id='6dus2'></ul>
                  本文介绍了使用带有多个输入字段的 jquery-ui 自动完成功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  大家下午好!

                  我节省了很多时间,阅读了关于 stackoverflow 的所有帖子......但我无法使用 multilpe 输入字段进行自动完成.我试图为每个输入分配一个autoc"类,我为每个字段使用不同的 id(实际上是 php 循环生成字段的 inedx).我不要求别人为我做这项工作......只是一个工作示例.

                  i spared a lot of time, read all posts on stackoverflow... and i am not able to make autocomplete working with multilpe input fields. I tried to attrib a 'autoc' class to each input, i use a different id for each field (in fact the inedx of the php loop generating fields). I do not ask someone to do the job for me.... just a working example.

                  提前致谢.

                  PS:我为我糟糕的英语道歉...

                  PS : I apologize for my poor english...

                  现在跟随一段html:

                  now follows a piece of html :

                      <input id="search_ctO" class="autoc" type="text" name="search_ct[]">
                      <input id="search_ct1" class="autoc" type="text" name="search_ct[]">
                      <input id="search_ct2" class="autoc" type="text" name="search_ct[]">
                      ....
                      <input id="search_ctn" class="autoc" type="text" name="search_ct[]">
                  

                  和 jquery :

                      $('.autoc').on("focus", function()   
                        $(this).autocomplete({
                         minLength: 2,
                         source: 'liste_contact.php',
                         select: function( event, ui ) {  
                           $('.autoc #search_ct').val( ui.item.label ); //id="search_ct'.$i.'
                           $(".autoc #contact_id").val( ui.item.value ); //
                           $("autoc #contact_description").val( ui.item.desc );
                           return false;
                         },  
                        change: function(){ 
                           var servi = $("#service_id").val();
                           var hop = $('#hop').val();
                           var contact = $("#contact_id" ).val();
                           $.ajax({
                             url: 'ajout_contact.php',
                             data: "serv="+ servi+"&hopit=" + hop+"&contact="+ contact+"",// on envoie la requete d'ajout de contact
                  
                           success: function() {
                                 $("#search_ct").val('');
                                 // location.reload(true);         
                         }
                  

                  推荐答案

                  如果不知道确切的 HTML 和传递给 autocomplete 源的对象数组,就很难准确地制作您的代码.

                  Without knowing the exact HTML and the object array passed to autocomplete source, it is difficult to make your code exactly.

                  但是,您已经询问了多个字段的 autocomplete 工作,所以这里只是一个简单的例子:

                  However, you have asked about working of autocomplete for multiple fields, so here is just a simple example:

                  HTML

                  <input id="search_ctO" class="autoc" type="text" name="search_ct[]"/>
                  <input id="search_ct1" class="autoc" type="text" name="search_ct[]"/>
                  <input id="search_ct2" class="autoc" type="text" name="search_ct[]"/>
                  <input id="search_ctn" class="autoc" type="text" name="search_ct[]"/>
                  

                  JS

                  var tags = ["abc","def","xyz"];
                  $('.autoc').on("focus", function(){
                        $(this).autocomplete({
                         minLength: 2,
                         source: tags
                          });
                  });
                  

                  JSFIDDLE 演示

                  如果您想在答案中包含任何其他内容,请随时发表评论.

                  If there is any other thing you want to be included in answer, feel free to comment.

                  编辑

                  您的代码,

                  $('.autoc').on("focus", function() {
                      $(this).autocomplete({
                          minLength: 2,
                          source: 'liste_contact.php',
                          select: function( event, ui ) {  
                              $('.autoc #search_ct').val( ui.item.label );
                              $(".autoc #contact_id").val( ui.item.value );
                              $(".autoc #contact_description").val( ui.item.desc );
                              return false;
                          },  
                          change: function() { 
                              var servi = $("#service_id").val();
                              var hop = $('#hop').val();
                              var contact = $("#contact_id" ).val();
                              $.ajax({
                                  url: 'ajout_contact.php',
                                  data: "serv="+servi+"&hopit="+hop+"&contact="+contact+"",
                                  success: function() {
                                      $("#search_ct").val('');        
                                  }
                              });
                          }
                      });
                  });
                  

                  这篇关于使用带有多个输入字段的 jquery-ui 自动完成功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  • <small id='7l6kL'></small><noframes id='7l6kL'>

                    1. <legend id='7l6kL'><style id='7l6kL'><dir id='7l6kL'><q id='7l6kL'></q></dir></style></legend>
                        <tbody id='7l6kL'></tbody>
                      <i id='7l6kL'><tr id='7l6kL'><dt id='7l6kL'><q id='7l6kL'><span id='7l6kL'><b id='7l6kL'><form id='7l6kL'><ins id='7l6kL'></ins><ul id='7l6kL'></ul><sub id='7l6kL'></sub></form><legend id='7l6kL'></legend><bdo id='7l6kL'><pre id='7l6kL'><center id='7l6kL'></center></pre></bdo></b><th id='7l6kL'></th></span></q></dt></tr></i><div id='7l6kL'><tfoot id='7l6kL'></tfoot><dl id='7l6kL'><fieldset id='7l6kL'></fieldset></dl></div>

                          • <bdo id='7l6kL'></bdo><ul id='7l6kL'></ul>
                            <tfoot id='7l6kL'></tfoot>