IcreatedthispluginbecauseIwasnothappywithanyoftheotherones.Thispluginwillgiveyousimple,cleanautocompletefunctionalityontheselectedtextbox.
Here'sthecode:
HTMLFile:
<formid="myform"> <inputtype="text"name="my_textbox"id="my_textbox"/></form><scripttype="text/javascript"><!--$(function() { vardata={ fn:'lookup' }; varoptions={ min_length:3, error_responses:[ "Noresults.", "Toomanyresults." ] }; $("#suggest").suggest("search.php",data,options);});--></script>
Exampleserver-sidePHPscript,search.php:
<?php//Preventcachingheader("Cache-Control:no-cache,must-revalidate"); //HTTP/1.1header("Expires:Jan1,2000"); //Dateinthepast$fn =$_GET['fn'];$allowed_fns=array('lookup');if(!in_array($fn,$allowed_fns)) {exit;}printcall_user_func($fn);functionlookup() { $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"Toomanyresults."; } if(count($results)===) { return"Noresults."; } $list=array(); foreach($resultsas$result) { $sn =$result['sn']; $gn =$result['givenname']; $uid=$result['uid']; $name="$sn,$gn($uid)"; array_push($list,$name); } returnimplode("\n",$list);}?>
评论