微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Yet Another Autocomplete

程序名称:Yet Another Autocomplete

授权协议: 未知

操作系统: 跨平台

开发语言: JavaScript

Yet Another Autocomplete 介绍

I created this plugin because I was not happy with any of the other ones. This
plugin will give you simple, clean autocomplete functionality on the selected
text Box.

Here’s the code:

HTML File:

<form id="myform"> <input type="text" name="my_textBox" id="my_textBox" /> </form> <script type="text/javascript"> <!-- $(function() { var data = { fn : 'lookup' }; var options = { min_length : 3, error_responses : [ "No results.", "Too many results." ] }; $("#suggest").suggest("search.PHP", data, options); }); --> </script>

Example server-side PHP script, search.PHP:

`<?PHP
// Prevent caching
header(“Cache-Control: no-cache, must-revalidate”); // HTTP/1.1
header(“Expires: Jan 1, 2000”); // Date in the past
$fn = $_GET[‘fn’];
$allowed_fns = array(‘lookup’);
if (!in_array($fn, $allowed_fns)) { exit; }
print call_user_func($fn);

function lookup() {
$q = valueIfSet($_GET[‘q’]);
$attrs = array(“uid”, “givenname”, “sn”);
$filter = “level03=95C”;
try {
$results = your_ldap_lookup_function($q, $attrs, $filter, true, , 1);
} catch (Exception $e) {
return “Too many results.”;
}
if (count($results) === ) {
return “No results.”;
}
$list = array();
foreach ($results as $result) {
$sn = $result[‘sn’];
$gn = $result[‘givenname’];
$uid = $result[‘uid’];
$name = “$sn, $gn ($uid)”;
array_push($list, $name);
}
return implode(“\n”, $list);
}
?>`

Yet Another Autocomplete 官网

http://plugins.jquery.com/project/YA_AutoComplete

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐