SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Oct 31, 2006, 13:01 #1
- Join Date
- Dec 2004
- Location
- USA
- Posts
- 1,407
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
scriptaculous autocomplete ALMOST working - help?
EDIT Nov 1: worked around the issue with javascirpt array.
The code below does bring up a list of names when typing begins. BUT, it brings the entire list every time no matter what you type. For example, I type an "m" in the field and the list starts with "A". Th elist has over a hundred so it should narrow the search as you type more, it does not.
I got the scriptaculous autocomplete.LOCAL to work fine. I can not use that version because I need to add an additional value the field (see documentation) and update a field afterUpdate.
The results.php is a database call that creates a file with proper scritaculous formatting like:
<ul><li>name1</li><li>name2</li><li>name3</li>...</ul>
Here's the code:
HTML Code:<input id="companies" name="companies" autocomplete="off" size="40" type="text" value="" /> <div class="page_name_auto_complete" id="company_list" style="display:none;border:1px solid black;background-color:white;"></div> <input type="hidden" name="company_id" id="company_id" value=""/> <script type="text/javascript"> <![CDATA[ new Ajax.Autocompleter('companies', 'company_list','results.php', {}); // ]]> </script>
Last edited by WebDevGuy; Nov 1, 2006 at 04:51.
-
Dec 20, 2006, 11:49 #2
- Join Date
- Dec 2006
- Posts
- 1
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
I asked myself the same question and finally found a solution (an easy one too. I posted it here:
http://wiki.script.aculo.us/scriptac....Autocompleter
Basically, all you do is extend your Class-call with a token paramName and then catch this param in your results.php (e.g. $_REQUEST["search"]) and use it in your SQL WHERE-clause:
HTML Code:<script type="text/javascript"> <![CDATA[ new Ajax.Autocompleter('companies', 'company_list','results.php', {paramName: 'search'}); // ]]> </script>
Cheers
Bookmarks