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://www.codercto.com/soft/d/21051.html

敏捷软件开发

敏捷软件开发

Robert C.Martin,、Micah Martin / 邓辉、孙鸣 / 人民邮电出版社 / 2010-12 / 79.00元

要想成为一名优秀的软件开发人员,需要熟练应用编程语言和开发工具,更重要的是能够领悟优美代码背后的原则和前人总结的经验——这正是本书的主题。本书凝聚了世界级软件开发大师Robert C. Martin数十年软件开发和培训经验,Java版曾荣获计算机图书最高荣誉——Jolt大奖,是广受推崇的经典著作,自出版以来一直畅销不衰。 不要被书名误导了,本书不是那种以开发过程为主题的敏捷软件开发类图书。在......一起来看看 《敏捷软件开发》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

SHA 加密
SHA 加密

SHA 加密工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器