ajax实现姓名的联想功能 ,input可以添加过个值
2018-03-07 15:22
411 查看
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>自动联想</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script> function bb(e) { function split(val) { return val.split(/,\s*/); } userName = document.getElementById("tagsTemp").value; userName = userName.substr(userName.lastIndexOf(',') + 1, userName.length).replace(/\s+/g, ""); /* console.log(userName); */ $("#tagsTemp").autocomplete({ minLength : 0, source : function(request, response) { $.ajax({ cache : true, type : "GET", /* url : "/testtest?userName='"+userName+"'", */ url : "/testtest", data : { userName : userName }, async : true, error : function(request) { alert("请求失败!"); }, success : function(data) { response($.map(data, function(item) { return { label : item.znName + " " + item.email, znName : item.znName, email : item.email } })); } }); }, select : function(event, ui) { var terms = split(this.value); /* $("#tagsTemp").attr('value', ui.item.znName); */ $("#tagsTemp").attr('data-value', ui.item.email); // remove the current input terms.pop(); terms.push(ui.item.value); terms.push(""); this.value = terms.join(", "); return false; } }); }; </script> </head> <body> <form id="testtesttest"> <div class="ui-widget"> <label for="tags">联想文本框: </label> <input oninput="bb(event)" id="tagsTemp" size="50" type="text" name="tagsTemp" value="" data-value=""> </div> </form> </body> </html>
相关文章推荐
- 不用ajax也能实现的功能!单击添加新行时可以删除这一行信息的源码
- JQuery实现的购物车功能(可以减少或者添加商品并自动计算价格)
- 完成一个学生管理程序,使用学号作为键添加5个学生对象,并可以将全部信息保存在文件中,可以实现对学生信息的学号查找,输出全部学生信息的功能。
- Ajax 和 XML: 使用 Ajax 实现打分评级和添加评论功能
- 99信息发布网,添加收藏,设置为首页功能,ie上可以实现的;
- 2.实现一个通讯录; 通讯录可以用来存储1000个人的信息,每个人的信息包括: 姓名、性别、年龄、电话、住址 提供方法: 1. 添加联系人信息 2. 删除指定联系人信息 3. 查找指定联
- jquery+json+struts2的ajax功能实现总结,折磨我3天希望可以帮助到你
- 完成一个学生管理程序,使用学号作为键添加5个学生对象,并可以将全部信息保存在文件中,可以实现对学生信息的学号查找,输出全部学生信息的功能。
- div中加入iframe,可以实现Ajax的功能
- jquery raty星级评分插件的具体使用(可以结合ajax和后台交互)以及点赞功能的实现
- 谁能用jQuery和Ajax做的访问ado.net程序-----跪求各位大侠(有相似的也可以,只要实现的是类似的功能就可以)
- ajax 如何实现搜索输入框联想功能
- 重写QLineEdit,实现编辑框内添加删除按钮的功能(随时把控件Move到一个地方,然后show就可以了,这是万能的办法)
- input输入框实现联想关键词功能
- Ajax 和 XML: 使用 Ajax 实现打分评级和添加评论功能
- 完成一个学生管理程序,使用学号作为键添加5个学生对象,并可以将全部信息保存在文件中,可以实现对学生信息的学号查找,输出全部学生信息的功能。
- 用c语言实现一个通讯录; 通讯录可以存储1000个人的信息,信息包括姓名、性别、年龄、电话、住址 提供方法: 1.添加联系人信息 2.删除指定联系人信息 3.查找指定联系人信息 4.修改指定联系&
- 完成一个学生管理程序,使用学号作为键添加5个学生对象,并可以将全部信息保存在文件中,可以实现对学生信息的学号查找,输出全部学生信息的功能。
- 实现一个通讯录; 通讯录可以用来存储1000个人的信息,每个人的信息包括: 姓名、性别、年龄、电话、住址 提供方法: 1. 添加联系人信息 2. 删除指定联系人信息 3. 查找指定