5 # name: LJ::JSUtil::autocomplete
7 # des: given the name of a form filed and a list of strings, return the
8 # JavaScript needed to turn on autocomplete for the given field.
9 # returns: HTML/JS to insert in an HTML page
14 my $fieldid = $opts{field
};
15 my @list = @
{$opts{list
}};
17 # create formatted string to use as a javascript list
18 @list = sort { lc $a cmp lc $b } @list;
19 @list = map { $_ = "\"$_\"" } @list;
20 my $formatted_list = join(",", @list);
23 <script type
="text/javascript">
24 function AutoCompleteFriends
(ele
) \
{
25 var keywords
= new InputCompleteData
([$formatted_list], "ignorecase");
26 new InputComplete
(ele
, keywords
);
28 if ('$fieldid' && \
$('$fieldid')) AutoCompleteFriends
(\
$('$fieldid'));