如何获取自动完成中文本的id(值) [英] how to take the id(value) of the of the text in autocomplete

查看:57
本文介绍了如何获取自动完成中文本的id(值)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$(function () {
            $("input#txtactname").autocomplete({
                source: function (request, response) {
                    // define a function to call your Action (assuming UserController)
                    $.ajax({
                        url: '/Admin/GetActName?Acname=' + $("#txtactname").val(),
                        type: "POST",
                        dataType: "json",
                        // query will be the param used by your action method
                        data: { query: request.term },
                        success: function (data) {
                            response($.map(data, function (item) {
                                return { label: item, value: item };
                            }))
                        }
                    });
                },
                minLength: 3,
                select: function (event, ui) {
                    alert(this.value);
                    return false;
                }// require at least one character from the user
            }).result(function (event, item) {
                alert(item.value);
                $('#hdnactid').val(item.value);

            });



        });

推荐答案

function (){


输入#txtactname)。autocomplete({
source: function (request,response){
// 定义一个函数来调用你的Action(假设UserController)
("input#txtactname").autocomplete({ source: function (request, response) { // define a function to call your Action (assuming UserController)


.ajax({
url:' / Admin / GetActName?Acname =' +
.ajax({ url: '/Admin/GetActName?Acname=' +


这篇关于如何获取自动完成中文本的id(值)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆