<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>jQuery Autocomplete Plugin</title>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type='text/javascript' src='../js/myautocomplete.js'></script>
<script type='text/javascript' src='../js/jquery.autocomplete.js'></script>
<link rel="stylesheet" type="text/css" href="../css/main.css" />
<link rel="stylesheet" type="text/css" href="../css/jquery.autocomplete.css" />
</head>
<body>
<div id="content">
<form autocomplete="on">
<p>
<label>
Month (local):
</label>
<input type="text" id="month" />
</p>
<p>
<label>
E-Mail
</label>
<input type="text" id="email" />
</p>
<p>
<label>
Tags (local):
</label>
<input type="text" id='tags' />
</p>
<p>
<label>
Image search (remote):
</label>
<input type="text" id='imageSearch' />
</p>
<p>
<label>
Multiple Cities (local):
</label>
<textarea id='suggest3' cols='40' rows='3'></textarea>
</p>
</form>
</div>
</body>
</html>
$().ready(function() {
$("#tags").autocomplete(["c++", "java", "php", "coldfusion", "javascript", "asp"], {
width : 320,
max : 4,
highlight : false,
multiple : true,
multipleSeparator : " ",
scroll : true,
scrollHeight : 300
});
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
$("#month").autocomplete(months, {
minChars : 0,
max : 12,
autoFill : true,
mustMatch : true,
matchContains : false,
scrollHeight : 220,
formatItem : function(data, i, total) {
// don't show the current month in the list of values (for whatever reason)
if (data[0] == months[new Date().getMonth()])
return false;
return data[0];
}
});
$("#imageSearch").autocomplete("../ImageSearchServlet", {
width : 320,
max : 4,
highlight : false,
scroll : true,
scrollHeight : 300,
formatItem : function(data, i, n, value) {
return "<img src='images/" + value + "'/> " + value.split(".")[0];
},
formatResult : function(data, value) {
return value.split(".")[0];
}
});
// function format(mail) {
// return mail.name + " <" + mail.to + ">";
// }
function format(row, i, max) {
return i + "/" + max + ": \"" + row.name + "\" [" + row.to + "]";
}
$("#email").autocomplete('../AutocompleteServlet', {
multiple : false,
parse : function(data) {
return $.map(eval(data), function(row) {
return {
data : row,
value : row.name,
result : row.name + " <" + row.to + ">"
}
});
},
// formatItem: function(item) {
// return format(item);
// }
formatItem : function(row, i, max) {
return row.name + " " + row.to;
}
}).result(function(e, item) {
//$("#content").append("<p>selected " + format(item) + "</p>");
});
var cities = ["Aberdeen", "Atwater", "Butler", "Byesville", "Cable", "Cadiz", "Dunkirk", "Dupont", "East Claridon", "East Fultonham", "Fulton", "Fultonham", "Galena",
"Galion", "Huntsville", "Huron", "Iberia", "Independence", "Johnstown", "Junction City", "Kalida", "Kansas", "Lynx", "Lyons", "Macedonia", "Macksburg", "Nova",
"Novelty", "Oak Harbor", "Oak Hill", "Portsmouth", "Potsdam", "Quaker City", "Quincy", "Racine", "Radnor", "Sylvania", "Syracuse", "Tallmadge", "Tarlton",
"Tuscarawas", "Twinsburg", "Uhrichsville", "Union City", "Vincent", "Vinton", "Wadsworth", "Wakefield", "Xenia", "Yellow Springs", "Yorkshire", "Zaleski",
"Zanesfield", "Zanesville", "Zoar"];
$("#suggest3").autocomplete(cities, {
multiple : true,
mustMatch : true,
autoFill : true
});
});
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @Title:AutocompleteServlet.java
* @Description:<br>
* <br>
* @Company:
* @author <a href="mailto:wang-yu@msn.com">WangYu</a></br>
* @version 1.0 <br>
* @since j2sdk1.4.2 <br>
*/
public class AutocompleteServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String q = request.getParameter("q");
Map map = new HashMap();
Set entrys = map.entrySet();
map.put("wangyu", "wang-yu@msn.com");
map.put("admin", "admin@msn.com");
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("[");
Iterator iterator = entrys.iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
//if(q.equals(entry.getKey().toString()))
stringBuffer.append("{ name: '" + entry.getKey() + "', to: '" + entry.getValue() + "' }, ");
}
stringBuffer.append("]");
System.out.println(stringBuffer);
System.out.println(q);
out.print(stringBuffer);
out.flush();
out.close();
}
}
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @Title:ImageSearchServlet.java
* @Description:<br>
* <br>
* @Company:
* @author <a href="mailto:wang-yu@msn.com">WangYu</a></br>
* @version 1.0 <br>
* @since j2sdk1.4.2 <br>
*/
public class ImageSearchServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String path = request.getParameter("q");
out.print("Antwerpen.jpg \n Antwerpen.jpg");
out.flush();
out.close();
}
}
分享到:
相关推荐
jQuery Autocomplete plugin是在jQuery的基础上开发的一套小巧的输入下拉提示插件,这是它的PHP应用实例,大部分功能与HTML格式网页类同,这里增加了一些需要PHp程序配合的内容,它不但有输入提示功能,而且示例本身...
在本主题中,我们将深入探讨基于jQuery的Autocomplete插件,并着重关注如何开发一个用于拼音输入的下拉列表插件。这个插件是为了解决中文输入时的搜索效率问题,通过提供拼音提示来帮助用户更快地找到所需内容。...
jQuery plugin: Autocomplete 参数及实例 官网:jQuery plugin: Autocomplete 此插件依赖于 jquery 1.2.6 --- jquery 1.8.3 转自:http://www.cnblogs.com/duanhuajian/p/3398904.html
jQuery plugin for autocomplete - jQuery自动完成插件
**jQuery Validation Plugin 知识详解** jQuery Validation Plugin 是一个用于前端表单验证的强大工具,它为jQuery用户提供了方便快捷的方法来验证用户输入的数据,确保数据的准确性和完整性。这个插件能够帮助...
jQuery的Autocomplete(自动完成、自动填充)插件有不少,但比较下来我感觉,还是bassistance.de的JQuery Autocomplete plugin比较强大,我们就来写一些代码感受一下。
- **jQuery Autocomplete Plugin with HTML formatting**: 支持HTML格式化的自动补全插件。 - **jQuery Autocompleter**: 简单易用的自动补全插件。 - **Auto Completer (Tutorial with PHP & MySQL)**: 教程展示...
- **jQuery Autocomplete Plugin**:另外一种实现自动完成的插件。 以上是jQuery插件的一些典型示例,它们覆盖了文件上传、表单验证、选择框处理、表单基础、时间日期选择以及搜索和评级等功能。这些插件极大地扩展...
- **jQuery Autocomplete Plugin with HTML formatting**: 支持HTML格式的自动完成搜索插件。 - **AutoCompleter (Tutorial with PHP & MySQL)**: 使用PHP和MySQL实现的自动完成搜索插件。 - **quickSearch jQuery ...
1. **官方网站**:访问官方网站 [http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/](http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/) 获取最新信息。 2. **版本要求**:当前...
jQuery Autocomplete Plugin with HTML formatting** - **功能概述**:支持HTML格式的自动补全结果。 - **应用场景**:适用于需要格式化自动补全结果的场景。 **6. jQuery Autocompleter** - **功能概述**:简洁的...
1、jquery.autocomplete参考地址 http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/ http://docs.jquery.com/Plugins/Autocomplete 2、jquery.autocomplete详解 语法: autocomplete(urlor data, ...
autocomplete官网 : http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/ (可下载jQuery autocomplete插件)。 淘宝商品搜索功能 效果: 下面来使用 autocomplete插件来实现类似效果。 1. 创建 ...
一个jquery开发的标签功能加强插件,可以生成或删除标签,还能对输入重复标签进行检查,和JQuery autocomplete插件配合实现自动完成功能。演示地址:http://www.jq22.com/jquery-info426
autocomplete官网 : http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/ (可下载jQuery autocomplete插件)。 淘宝商品搜索功能 效果: 下面来使用 autocomplete插件来实现类似效果。1. 创建 ...
6. Farbtastic jQuery Color Picker Plugin:色彩选取器。 7. Color Picker by intelliance.fr:颜色选择组件。 **投票插件**: 1. jQuery Star Rating Plugin:星级评分。 2. jQuery Star Rater:星评系统。 3. ...
jQuery Tags Input Plugin是一款基于jQuery开发的插件,它的主要作用是为网页中的输入框增加标签的添加和删除功能。该插件可以方便地实现标签输入,自动检查输入的标签是否有重复,并且可以和jQuery autocomplete...
- jQuery Form’n Field plugin:进一步增强表单处理。 - jQuery Checkbox manipulation:控制复选框的行为。 - jTagging:实现标签输入功能。 - jQuery labelcheck:使标签更具交互性。 - Overlabel:让标签...