Yet Another Autocomplete 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
Yet Another Autocomplete 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
Yet Another Autocomplete 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 未知
开发语言 JavaScript
操作系统 跨平台
软件类型 开源软件
开源组织
地区 不详
投 递 者 不详
适用人群 未知
收录时间 2008-09-19

软件简介

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);
}
?>
展开阅读全文

评论

点击加入讨论🔥(1) 发布并加入讨论🔥
暂无内容
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
暂无内容
1 评论
1 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部