weixin_33726313 2012-08-06 12:18 采纳率: 0%
浏览 15

自动完成不完全

I have written an autocomplete function. When I click on #input3 it starts to generate what I have typed.

Example: "apple" I type "app" and I click to select "apple". What I select should be sent to the src and updated in #input2.

Problem: What is sent to the src is what I have typed and not what I have selected. Why?

.autocomplete({
    source: function(request, response) {
        $.ajax({
            url: src,
            fillin:true,
            dataType: "json",
            data: {
                term : request.term,
                c3 : $("#input3").val()
                },
            success: function(data){
                response(data)
                }
            });
        },
    minLength: 0,
    delay: 300
    })
.change(function(request2, response) {
    $.ajax({
        url: src,
        dataType: "json",
        data: {
            term : request2.term,
            c1 : "search",
            c3: $("#input3").val()
            },
        success: function(data){
            $("#input2").val(data);
            }
        });
    })
  • 写回答

2条回答 默认 最新

  • weixin_33712881 2012-08-06 13:33
    关注

    You can use the change event in jquery ui autocomplete:

     $("#your_input_id").autocomplete({
                source: availableTags,
                change: function(){
                console.log($(this).val());//selected value
                }
     });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 SQL Server下载
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求