防百度的模糊搜索

论坛 期权论坛 脚本     
匿名技术用户   2021-1-3 17:19   11   0

做一个防百度的模糊搜索查询下拉;

先写一个input输入框;下载http://jqueryui.com/download/ 插件

<tr class="table-responsive">
    <td>
 店铺名称:
 <input type="text" name="phName" value="" id="phName" placeholder="模糊搜索," class="rph" size='50' >
 <input type="hidden" name="rpId" id="rpId"  />
    </td>
</tr>




<script>
window.οnlοad=function(){  
    $(".rph").autocomplete({  
           minLength: 0,  
           source: function( request, response ) {  
           //干你想干的事情
           
               $.ajax({  
                    url : "__CONTROLLER__/getshopcode",  
                    type : "post",  
                    dataType : "json",  
                    data : {"shopname":$(".rph").val()},  
                      
                   success: function( data ) {  
                         console.log(data);  
                         response( $.map( data, function( item ) {  
                               return {  
                                 label: item.shopname,  
                                 value: item.shopcode  
                               }  
                         }));  
                   }  
              });  
           },  
           focus: function( event, ui ) {  
               $(".rph").val( ui.item.label );  
               $("#rpId").val( ui.item.value );  
                 return false;  
               },  
           select: function( event, ui ) {  
         console.log(ui);
         $(".rph").val( ui.item.label );  
                          $("#rpId").val( ui.item.value ); 
     }
            }
           }
       })
      }

原文地址https://xgs888.top/post/view?id=40


分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP