Yet Another Autocomplete

码农软件 · 软件分类 · jQuery自动完成插件 · 2019-12-13 11:41:42

软件介绍

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);
}
?>

本文地址:https://codercto.com/soft/d/21051.html

Algorithms to Live By

Algorithms to Live By

Brian Christian、Tom Griffiths / Henry Holt and Co. / 2016-4-19 / USD 30.00

A fascinating exploration of how insights from computer algorithms can be applied to our everyday lives, helping to solve common decision-making problems and illuminate the workings of the human mind ......一起来看看 《Algorithms to Live By》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

随机密码生成器
随机密码生成器

多种字符组合密码