zoukankan      html  css  js  c++  java
  • 自动补全(备份)

    1、页面添加标签

    <datalist id="setdatalist"></datalist>

    2、input框添加属性   list="setdatalist" 

     <input type="text" id="mainNumber1"  name="mainNumber1" list="setdatalist"  class="text" />

    3、$(document).ready(function()  下面 添加监听

      $('#mainNumber1').bind('input propertychange click focus', function() {
                $("#setdatalist").empty(); 
                var parameter = $("#departureTime").val();
                $.ajax({
                    type : "POST", 
                    url:'automaticCompletionTool.do?setZdbq&type=1&keyword='+this.value+"&parameter="+parameter,
                    success: function(data){
                        var json=eval("("+data+")") ;
                        for(var i=0;i<json.queryForList.length;i++){
                            $('#setdatalist option:first').attr("selected",true);
                            if($('#setdatalist option').length < json.queryForList.length){
                                $("#setdatalist").append('<option value="'+json.queryForList[i].code+'"></option>');
                            }
                        }
                    }
                });
        })

    4、后台添加工具类(这里已经添加过了,接着后面type用其他值就行了 )

    package com.jeecg.tool;
    
    import java.io.IOException;
    import java.util.List;
    import java.util.Map;
    
    import javax.annotation.Resource;
    import javax.servlet.http.HttpServletRequest;
    
    import org.jeecgframework.core.util.StringUtil;
    import org.springframework.jdbc.core.JdbcTemplate;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    import com.alibaba.fastjson.JSONObject;
    /**
     * 
     * @author xuebl 文本框自动补全工具
     * @date 2021年7月6日 上午10:13:49
     */
    @Controller
    @RequestMapping("/automaticCompletionTool")
    public class AutomaticCompletionTool {
         @Resource
         private JdbcTemplate jdbcTemplate;
        
         /**
          * @Description: 自动补全
          * @author xuebl
          * @date 2021年7月6日 上午10:15:50 
          * @param request
          * @return
          * @throws IOException
          */
         @RequestMapping(params = "setZdbq")
         @ResponseBody
         public JSONObject setZdbq(HttpServletRequest request) throws IOException {
             String type=request.getParameter("type"); //接收传入的id值 
             String keyword=request.getParameter("keyword"); //接收传入的value值
             String parameter=request.getParameter("parameter"); //接收传入的其他参数
             String wheresql = "";
             String sql ="";
             JSONObject job = new JSONObject();
             try {
                  //航空主单号
                  if(type.equals("1")){
                      //航班日期选择时
                      if(StringUtil.isNotEmpty(parameter)){
                         wheresql = " and departure_time = '"+parameter+"' ";
                      }
                    sql = " select a.main_number code from aviation_info a where main_number like '%"+keyword+"%' "+wheresql+" limit  ";
                  } 
                  // System.out.println(sql);
                  sql +="8";
                  List<Map<String, Object>> queryForList = jdbcTemplate.queryForList(sql);
                  job.put("queryForList", queryForList);
             } catch (Exception e) {
                 // TODO: handle exception
             }
            
            
    
             return job;
         }
    } 
  • 相关阅读:
    浅谈CSS盒子模型
    JS中的prototype
    Underscore.js(JavaScript对象操作方法)
    stylus--css 框架使用方法
    LESS CSS 框架简介与使用
    三个 CSS 预处理器(框架):Sass、LESS 和 Stylus
    三.jquery.datatables.js表格编辑与删除
    二.jquery.datatables.js表格数据添加
    git-分支使用方式
    vue2购物车ch2-(商品列表显示)
  • 原文地址:https://www.cnblogs.com/xueblvip/p/14975944.html
Copyright © 2011-2022 走看看